Skip to main content

Distinction between press and release key events

1 reply [Last post]
palestrina
Offline
Joined: 2009-04-21
Points: 0

Hi!

I want to create a subclass of AbstractLayerUI and catch the key events. I need the information, if the key for the KeyEvent has been pressed or released. Does the processKeyEvent method register only for the pressed events or does it catch pressed as well as released events and how do I figure out what happened?

Thx,

Mathias

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
alexfromsun
Offline
Joined: 2005-09-05
Points: 0

Hello Mathias

You should check the KeyEvent.getID() value

see KeyEvent.paramString() :

[code]
switch (id) {
case KEY_PRESSED:
str.append("KEY_PRESSED");
break;
case KEY_RELEASED:
str.append("KEY_RELEASED");
break;
case KEY_TYPED:
str.append("KEY_TYPED");
break;
[/code]

Thanks
alexp