|
Author |
Topic: keyboard special keys (Read 484 times) |
|
Josh Nimoy
|
keyboard special keys
« on: Jan 29th, 2003, 11:09am » |
|
on a PC, all the special keys (F1, arrows, ctrl, shift) all show up as key 65535 in Proce55ing. If 65535 also occurs similarly for other OSes, perhaps then is would be nice to have a specialKey() function to retrieve the value, should key ever be 65535. I would love to have at least the arrow keys.
|
|
|
|
fry
|
Re: keyboard special keys
« Reply #1 on: Jan 30th, 2003, 3:25am » |
|
yep.. under java, there's a distinction between the key 'char' (which is what we provide with the 'key' variable) and the key 'code', which is a special constant for all the odd characters. since more people seem to want to do this, we should add keyCode as a variable as well (will try that for 51/52). in the meantime, check out this discussion for info on how to do it: http://proce55ing.net/discourse/yabb/board_Syntax_action_displa_y_num_1042156938.html
|
|
|
|
fry
|
Re: keyboard special keys
« Reply #2 on: Jun 25th, 2003, 8:42pm » |
|
i've added in support for handling ALT, CONTROL, SHIFT and the arrow keys (UP, DOWN, LEFT, RIGHT) without all that extra difficulty for 56.
|
|
|
|
skloopy
|
Re: keyboard special keys
« Reply #3 on: Nov 16th, 2003, 10:09am » |
|
With the new code for UP, DOWN, etc.. how would i pass the "key" variable to a function like this: Code:void keyTyped() { typeKey(key); } void typeKey(??int?? key) { switch(key) { case DOWN: make some crepes; break; } } |
| the ?? is just cause i don't know what type to cast it as, because it doesn't seem to keep the DOWN connection once it gets passed as an int.
|
|
|
|
REAS
|
Re: keyboard special keys
« Reply #4 on: Dec 16th, 2003, 7:03pm » |
|
int is correct. it's working in this example: Code: void keyPressed() { passedkey(key); } void passedkey(int keyin) { println(key); if(key == DOWN) { println("DOWN"); } } |
|
|
|
|
|
REAS
|
Re: keyboard special keys
« Reply #5 on: Dec 16th, 2003, 7:05pm » |
|
also working here: Code: void keyPressed() { passedkey(key); } void passedkey(int keyin) { println(key); //if(key == DOWN) { // println("DOWN"); //} switch(key) { case DOWN: println("DOWN"); break; } } |
|
|
|
|
|
|