|
Author |
Topic: Using Cursor Keys (Read 887 times) |
|
Dara
|
Using Cursor Keys
« on: Jan 10th, 2003, 1:02am » |
|
Does Proce55ing know when cursor keys are pressed? What are the constants for <UP>, <LEFT>, <RIGHT>, <DOWN> keys?
|
« Last Edit: Jan 10th, 2003, 3:42pm by Dara » |
|
|
|
|
JimQode
|
Re: Using Cursor Keys
« Reply #1 on: Jan 10th, 2003, 5:02pm » |
|
I would also want to know how to trap special keys like cursor keys in p5. I tried the java method but to no avail. please help! Jim
|
--- End Of Transmission ---
|
|
|
fry
|
Re: Using Cursor Keys
« Reply #2 on: Jan 10th, 2003, 5:11pm » |
|
something like this should work: Code:public void keyPressed(KeyEvent e) { switch (e.getKeyCode()) { case KeyEvent.VK_UP: // do something break; case KeyEvent.VK_UP: // do something break; case KeyEvent.VK_UP: // do something break; case KeyEvent.VK_UP: // do something break; } } |
| in this case you're switching into regular java.. you don't have to use 'switch' by any means, but it's often cleaner (and faster, and better coding practice) than a whole mess of 'if' statements.
|
|
|
|
|