So, I know that the keyCodes are different for the numpad and that they actually if you have NumLock on or off. I have a little program that gets the numbers for me:
void setup() {
}
void draw() {
}
void keyPressed() {
println(key, keyCode);
}
So, for the 5 button, it’s supposed to be either 101 or 12 (numLock on vs or off, respectively) as it is with the above program. However, my big program which scans with button inputs, is acting weird. For the numLock on/off, it’s giving 133/12.
Also, for the 9, it should be 105/33, but instead is 137/16, and 16 is supposed to be the shift keyCode, which is making things even more troublesome… so both can be wrong.
(the function is just meant to active on button presses and set the Input objects, which have pre-saved codes, to true if it matches… shouldn’t be changing anything about the keyCode itself)
void keyPressed() {
println("code:", keyCode); // check what was just pressed
// update inputs
for (int i = 0; i < inputs.length; i++)
// go through inputs and check if the input has a corresponding keyCode, and set the pressed of the same spot to true
for (int j = 0; j < inputs[i].code.length; j++)
for (int k = 0; k < inputs[i].code[j].length; k++)
if (keyCode == inputs[i].code[j][k])
inputs[i].pressed[j] = true;
}
Here’s a small table with the numLock on/off and what it should be (correct) vs what it is instead (false), in case there’s a pattern.
Button correct false
1 97/35 129/3
2 98/40 130/40
3 99/34 131/11
4 100/37 132/37
5 101/12 133/12
6 102/39 134/39
7 103/36 135/2
8 104/38 136/38
9 105/33 137/16
I can see that it’s offset on the numLock on being +22, but not sure how or why it’s like that. When numLock is off and they are functions, only the corners (1, 3, 7, 9) are different while the arrows (and 5) are the same.
Also, the “home” key above the numLock that shares the same function as the 7 when numLock is off has the same code in both programs as whichever the 7 is, same with the delete key and delete beside the numPad 0… but none of the letters or normal functions (enter, backspace, space, shift) are showing that behaviour.
If anyone knows about how this works or why it might be happening between the 2 programs, I would greatly appreciate any insight, as I can’t seem to figure out why the codes are acting differently.