## org.gnu.gtk.event
Class KeyEvent

    java.lang.Object
      org.gnu.gtk.event.GtkEvent
          org.gnu.gtk.event.KeyEvent

All Implemented Interfaces:
  java.io.Serializable

public class KeyEvent
extends GtkEvent

This event object is used to identify when a key has been pressed and released. In particular, it allows you to get at which key was pressed - see `getKeyval()`.

See Also:
  `An example of how to listen for KeyEvents`, `KeyValue`, Serialized Form

Nested Class Summary
`static class` `KeyEvent.Type`

Constructor Summary
`KeyEvent(java.lang.Object source, KeyEvent.Type type, EventKey gdkEvent)` Construct a KeyEvent object.

Method Summary
`int` `getKeyval()` Returns the key value.
`int` `getLength()` Returns the length of the String that resulted from this keypress (see `getString()`).
`ModifierType` `getModifierKey()` Returns the modifier key used.
`java.lang.String` `getString()` Get the "null-terminated multi-byte string containing the composed characters resulting from the key press".
`boolean` `isOfType(KeyEvent.Type test)` Test to compare events.

Methods inherited from class org.gnu.gtk.event.GtkEvent
`getSource, getType, toString`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### KeyEvent

    public KeyEvent(java.lang.Object source,
                    KeyEvent.Type type,
                    EventKey gdkEvent)

  Construct a KeyEvent object.

Method Detail

### isOfType

    public boolean isOfType(KeyEvent.Type test)

  Test to compare events.

### getKeyval

    public int getKeyval()

  Returns the key value. Example:

            if (key == KeyValue.Return) {
                ...
            }

  Returns:
    an int, the key value. See `KeyValue` for the comprehensive list of values.

### getLength

    public int getLength()

  Returns the length of the String that resulted from this keypress (see `getString()`).

  Returns:
    int

### getModifierKey

    public ModifierType getModifierKey()

  Returns the modifier key used.

  Returns:
    (see `ModifierType`)

### getString

    public java.lang.String getString()

  Get the "null-terminated multi-byte string containing the composed characters resulting from the key press".

  FIXME: Isn't null termination hidden in Java? And, in any case, characters in Strings in Java are multi-byte. So does this work right nor not?

  Returns:
    String the character(s) resulting from the key press.