View Single Post
Old Jul 18th, 2006, 7:43 PM   #4
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 936
Rep Power: 4 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
You shouldn't compare key codes to plain integers; they make your code difficult to read and maintain.

When in doubt, look it up in the Java docs. In this case, the documentation for KeyEvent is particularly useful. Note the enormous number of static int fields; those are what you should be comparing your KeyEvent to. For example, the following will test whether the key pressed is the up arrow key:

if (event.getKeyCode() == KeyEvent.VK_UP) ...
titaniumdecoy is offline   Reply With Quote