// lista de constantes para las teclas..
// -------------------------------------
final int _UP = 38;
final int _DOWN = 40;
final int _LEFT = 37;
final int _RIGHT = 39;
final int _SPACE = 32;
final int _ESC = 27;
final int _ENTER = 10;
final int _F1 = 112;
final int _F2 = 113;
final int _F3 = 114;
final int _F4 = 115;
final int _F5 = 116;
final int _F6 = 117;
final int _F7 = 118;
final int _F8 = 119;
final int _F9 = 120;
final int _F10 = 121;
final int _PRINT = 154;
final int _BLOQ = 145;
final int _PAUSE = 19;
final int _A = 65;
final int _B = 66;
final int _C = 67;
final int _D = 68;
final int _E = 69;
final int _F = 70;
final int _G = 71;
final int _H = 72;
final int _I = 73;
final int _J = 74;
final int _K = 75;
final int _L = 76;
final int _M = 77;
final int _N = 78;
final int _O = 79;
final int _P = 80;
final int _Q = 81;
final int _R = 82;
final int _S = 83;
final int _T = 84;
final int _U = 85;
final int _V = 86;
final int _W = 87;
final int _X = 88;
final int _Y = 89;
final int _Z = 90;
final int _a = 65 + 32;
final int _b = 66 + 32;
final int _c = 67 + 32;
final int _d = 68 + 32;
final int _e = 69 + 32;
final int _f = 70 + 32;
final int _g = 71 + 32;
final int _h = 72 + 32;
final int _i = 73 + 32;
final int _j = 74 + 32;
final int _k = 75 + 32;
final int _l = 76 + 32;
final int _m = 77 + 32;
final int _n = 78 + 32;
final int _o = 79 + 32;
final int _p = 80 + 32;
final int _q = 81 + 32;
final int _r = 82 + 32;
final int _s = 83 + 32;
final int _t = 84 + 32;
final int _u = 85 + 32;
final int _v = 86 + 32;
final int _w = 87 + 32;
final int _x = 88 + 32;
final int _y = 89 + 32;
final int _z = 90 + 32;
boolean[] keys = new boolean[256];
//.............................................................................................................................................................
void keyPressed() {
if(key == CODED) {
//println("KEY CODED PRESSED: " + keyCode);
keys[keyCode] = true;
}
if (key<256) {
keys[key] = true;
//println(keyCode + " " + key);
}
}
//.............................................................................................................................................................
void keyReleased() {
// esta llamada controla la entrada de texto por teclado..
// el codigo esta en el mod_keyboard...
//keyboardCore();
//.............
if(key == CODED) {
//println("KEY CODED RELEASED: " + keyCode);
keys[keyCode] = false;
}
if (key<256) {
keys[key] = false;
}
}
//.............................................................................................................................................................
boolean key(int code) {
return keys[code];
}
Answers
Which kind of input do you want to track?? You can assing Mouse inputs oder Key inputs of the keyboard for example.
And there are several Events that are called every time a input is taken by the user.
For Example:
You can move the white rect by pressing the arrow keys.
add this to your program:
And now in your draw() main function add this:
This code is multikey capable ;)
All i wanted was if the user presses 4 x=4 sort of thing
https://forum.Processing.org/two/discussion/comment/2555/#Comment_2555
in a new function that you have to write named "
checkInputText()
"If you only want numbers 0..9 it's easy: you can say
inputText = key;
For numbers 10...9999 or so: