0
Using KeyListeners
I am trying to use the java awt KeyListener and I can't get it to work. Every tutorial that I watch all use the graphics system for jframes. How can I use the normal KeyListener without this?
1 Antwort
+ 1
*CODE NOT TESTED*
this is the way i use keyListener...
______________________________________________
TextArea area = new TextArea();
area.setKeyListener(new HotKeys());
class HotKeys() implements KeyListener {
@Override
public void keyPressed(KeyEvent e){
int key = e.getKeyCode();
if(key == KeyEvent.VK_SPACE){
System.out.println("space pressed");
}
}
}
_____________________________________