org.gnu.gtk.event
public interface KeyListener
Widget
using the
{@link org.gnu.gtk.Widget#addListener(KeyListener)}
method.
An example of using this to trap the Escape key:
Window window; ... window.addListener(new KeyListener() { public boolean keyEvent(KeyEvent event) { int key = event.getKeyval(); if (key == KeyValue.Escape) { window.hide(); return true; } else { return false; } } });
See Also: KeyEvent The list of KeyEvent types
Method Summary | |
---|---|
boolean | keyEvent(KeyEvent event)
Process a keystroke.
|
Parameters: event gives you access to the various methods which help you identify the keystroke. See {@link KeyEvent#getKeyval()}
Returns: Return true if you have handled the keystroke and do not want it to propagate to the default GTK handlers. Returning false will allow the keystroke to go upstream after you're done doing whatever you're doing.