Can't modify other keys with shift?
in
Programming Questions
•
23 days ago
- boolean wkey = false;
- boolean skey = false;
- boolean akey = false;
- boolean dkey = false;
- boolean shiftkey = false;
- void setup() {
- size(100,100,P2D);
- noStroke();
- fill(0);
- }
- void draw() {
- background(255);
- textAlign(LEFT,TOP);
- text("W: " + wkey,0,0);
- text("S: " + skey,0,10);
- text("A: " + akey,0,20);
- text("D: " + dkey,0,30);
- text("Shift: " + shiftkey,0,50);
- }
- void keyPressed() {
- if(key == 'w') {
- wkey = true;
- }
- if(key == 's') {
- skey = true;
- }
- if(key == 'a') {
- akey = true;
- }
- if(key == 'd') {
- dkey = true;
- }
- if(key == CODED) {
- if(keyCode == SHIFT) {
- shiftkey = true;
- }
- }
- }
- void keyReleased() {
- if(key == 'w') {
- wkey = false;
- }
- if(key == 's') {
- skey = false;
- }
- if(key == 'a') {
- akey = false;
- }
- if(key == 'd') {
- dkey = false;
- }
- if(key == CODED) {
- if(keyCode == SHIFT) {
- shiftkey = false;
- }
- }
- }
Using the above code I tested functionality with multiple keys at the same time and found that while shift is held down keyPressed events won't trigger (though keyReleased events will). This kind of seems odd considering how shift is usually a modifier key, so is there any way I can know when someone presses SHIFT + W and etc?
1