org.gnome.gtk

## Interface Widget.KeyPressEvent

- Enclosing class:
    Widget

      public static interface Widget.KeyPressEvent

  Handler interface for key press events. While ordinarily the user pressing a key is generally more interesting (in terms of "what key stroke did we get"), it should be noted that by the conventions of modern graphical user interfaces, them releasing a key is when a program should take action if action is called for. For example, if they press and hold the `Enter` key while the pointer is over a Button, but then move the mouse off of that Button, subsequently releasing won't cause that Button to activate).

  When hooking this up, you'll probably be wanting the key that was hit. That's accomplished with Call `event.getKeyval()` as in:

       foo.connect(new Widget.KeyPressEvent() {
           public boolean onKeyPressEvent(Widget source, EventKey event) {
               final Keyval key;
               final ModifierType mod;

               key = event.getKeyval();
               mod = event.getState();

               if (key == Keyval.Up) {
                   // go up!
               }
               return false;
           }
       });

  but see `Keyval` for a long discussion of the interpretation and use of keystrokes. Also note that reacting to a key stroke does not imply intercepting it; returning `false` and letting the default handlers in GTK carry on with things is usually what you want to do.

  The release half of this is `Widget.KeyReleaseEvent` as you might expect.

  Since:
    4.0.3
  Author:
    Andrew Cowie

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `onKeyPressEvent(Widget source, EventKey event)` As with other event signals, returning `false` means "I didn't [fully] handle this signal, so proceed with the next (ie, usually the default) handler" whereas if you return `true` you mean "I have handled this event, and wish to stop further emission of the signal".

- - ### Method Detail

    - #### onKeyPressEvent

          boolean onKeyPressEvent(Widget source,
                                EventKey event)

      As with other event signals, returning `false` means "I didn't [fully] handle this signal, so proceed with the next (ie, usually the default) handler" whereas if you return `true` you mean "I have handled this event, and wish to stop further emission of the signal".