Package com.tonic.vellum.input
Class KeyEvent
- java.lang.Object
-
- com.tonic.vellum.input.KeyEvent
-
public final class KeyEvent extends java.lang.ObjectAn immutable, normalized key event. The terminal driver translates raw escape sequences into these.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanalt()charch()static KeyEventcharacter(char ch)Creates a printable character event with no modifiers.static KeyEventcharacter(char ch, boolean ctrl, boolean alt, boolean shift)Creates a printable character event with modifiers.Keycode()booleanctrl()booleanis(Key k)booleanshift()static KeyEventspecial(Key code)Creates a non-printable key event with no modifiers.static KeyEventspecial(Key code, boolean ctrl, boolean alt, boolean shift)Creates a non-printable key event with modifiers.java.lang.StringtoString()
-
-
-
Constructor Detail
-
KeyEvent
public KeyEvent(Key code, char ch, boolean ctrl, boolean alt, boolean shift)
Creates a key event.- Parameters:
code- the logical keych- the character, valid whencodeis CHARctrl- whether the Ctrl modifier is heldalt- whether the Alt modifier is heldshift- whether the Shift modifier is held
-
-
Method Detail
-
special
public static KeyEvent special(Key code)
Creates a non-printable key event with no modifiers.- Parameters:
code- the logical key- Returns:
- the key event
-
special
public static KeyEvent special(Key code, boolean ctrl, boolean alt, boolean shift)
Creates a non-printable key event with modifiers.- Parameters:
code- the logical keyctrl- whether the Ctrl modifier is heldalt- whether the Alt modifier is heldshift- whether the Shift modifier is held- Returns:
- the key event
-
character
public static KeyEvent character(char ch)
Creates a printable character event with no modifiers.- Parameters:
ch- the character- Returns:
- the key event
-
character
public static KeyEvent character(char ch, boolean ctrl, boolean alt, boolean shift)
Creates a printable character event with modifiers.- Parameters:
ch- the characterctrl- whether the Ctrl modifier is heldalt- whether the Alt modifier is heldshift- whether the Shift modifier is held- Returns:
- the key event
-
code
public Key code()
- Returns:
- the logical key
-
ch
public char ch()
- Returns:
- the character, valid when
code() == CHAR
-
ctrl
public boolean ctrl()
- Returns:
- true when the Ctrl modifier is held
-
alt
public boolean alt()
- Returns:
- true when the Alt modifier is held
-
shift
public boolean shift()
- Returns:
- true when the Shift modifier is held
-
is
public boolean is(Key k)
- Parameters:
k- the key to compare against- Returns:
- true when this event's logical key equals k
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-