Package swingtree.input
Class Keyboard
java.lang.Object
swingtree.input.Keyboard
This is a simple Singleton class representing the current state of the keyboard.
It is not a keyboard shortcut implementation but merely a fast API to check if
a certain key on the keyboard has been pressed...
The keyboard class can not be used to hook up lambda callbacks, but merely ought
to serve as a convenient way to query the current state of the keyboard!
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThis enum represents all the keys on the keyboard which can be queried for their current state. -
Method Summary
Modifier and TypeMethodDescriptionstatic Keyboardget()Exposes the singleton instance of theKeyboardclass.booleanisPressed(Keyboard.Key key) This method checks if the suppliedKeyboard.Keyis currently pressed on the keyboard.
-
Method Details
-
get
Exposes the singleton instance of theKeyboardclass.- Returns:
- The singleton instance of the
Keyboardclass.
-
isPressed
This method checks if the suppliedKeyboard.Keyis currently pressed on the keyboard.- Parameters:
key- An instance of theKeyboard.Keyenum representing a keyboard key.- Returns:
- The truth value determining if the specified
Keyboard.Keytype is currently pressed by the user. - Throws:
NullPointerException- If the suppliedKeyboard.Keyis null, useKeyboard.Key.NONEinstead to check if no key is currently pressed.
-