FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Syntax
(Moderators: fry, REAS)
   Using Cursor Keys
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: Using Cursor Keys  (Read 887 times)
Dara

WWW Email
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

251091251091 Email
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


WWW
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.
 
Pages: 1 

« Previous topic | Next topic »