Package limn.scene.event
Class KeyEvent
java.lang.Object
limn.scene.event.InputEvent
limn.scene.event.KeyEvent
A keyboard event routed to the focused widget (bubbling to its ancestors
until consumed). Key codes and modifiers follow
Keys.
A key is told two ways. key() is the physical key, where it sits on the keyboard,
named after the key at that place on a US layout: what a game wants, since W is up wherever the
layout moved the letter. shortcutKey() is the key the active layout prints there when it
is a letter or a digit: what a shortcut wants, since the user reads Ctrl+Z off the keycap, and on
a French AZERTY keyboard the key printed Z is where a US layout has W.
-
Constructor Summary
ConstructorsConstructorDescriptionKeyEvent(int key, boolean pressed, boolean repeat, int modifiers) A key transition on a US layout, where the key printed on a keycap is the physical key's name: what a test types.KeyEvent(int key, int layoutCodePoint, boolean pressed, boolean repeat, int modifiers) A key transition. -
Method Summary
Modifier and TypeMethodDescriptionbooleanWhether this is a press (or auto-repeat) rather than a release.booleanisRepeat()intkey()The physical key, as aKeysconstant: where it is on the keyboard, whatever the layout prints on it, named after the key at that place on a US layout.intintModifier mask held during the event; test it with theKeys.MOD_*bits.intThe key a shortcut is read from: the letter or digit the active layout prints on this key, as theKeysconstant of that letter or digit, andkey()for every other key.toString()Methods inherited from class limn.scene.event.InputEvent
consume, isConsumed
-
Constructor Details
-
KeyEvent
public KeyEvent(int key, boolean pressed, boolean repeat, int modifiers) A key transition on a US layout, where the key printed on a keycap is the physical key's name: what a test types.- Parameters:
key- the physical key, aKeysconstantpressed- a press or an auto-repeat rather than a releaserepeat- an auto-repeatmodifiers- theKeys.MOD_*bits held
-
KeyEvent
public KeyEvent(int key, int layoutCodePoint, boolean pressed, boolean repeat, int modifiers) A key transition.- Parameters:
key- the physical key, aKeysconstantlayoutCodePoint- what the active layout types at that key with no modifier held, or0for a key that types nothing (an arrow, a function key)pressed- a press or an auto-repeat rather than a releaserepeat- an auto-repeatmodifiers- theKeys.MOD_*bits held
-
-
Method Details
-
key
public int key()The physical key, as aKeysconstant: where it is on the keyboard, whatever the layout prints on it, named after the key at that place on a US layout. -
layoutCodePoint
public int layoutCodePoint()- Returns:
- what the active layout types at this key with no modifier held, as a code point, or
0for a key that types nothing
-
shortcutKey
public int shortcutKey()The key a shortcut is read from: the letter or digit the active layout prints on this key, as theKeysconstant of that letter or digit, andkey()for every other key. On AZERTY the key where a US layout has W answersKeys.Z, so Ctrl+Z is the key the user sees Z on; a layout whose letters are not Latin (Cyrillic, Greek) answers the physical key, as native applications do, so Ctrl+Z stays where Z is on a US keyboard.- Returns:
- a
Keysconstant
-
isPressed
public boolean isPressed()Whether this is a press (or auto-repeat) rather than a release. -
isRepeat
public boolean isRepeat()- Returns:
truefor auto-repeat presses
-
modifiers
public int modifiers()Modifier mask held during the event; test it with theKeys.MOD_*bits. -
toString
-