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 common way to query the current state of the keyboard!
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
This enum represents all the keys on the keyboard which can be queried for their current state. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Keyboard
get()
Exposes the singleton instance of theKeyboard
class.boolean
isPressed
(Keyboard.Key key) This method checks if the suppliedKeyboard.Key
is currently pressed on the keyboard.
-
Constructor Details
-
Keyboard
public Keyboard()
-
-
Method Details
-
get
Exposes the singleton instance of theKeyboard
class.- Returns:
- The singleton instance of the
Keyboard
class.
-
isPressed
This method checks if the suppliedKeyboard.Key
is currently pressed on the keyboard.- Parameters:
key
- An instance of theKeyboard.Key
enum representing a keyboard key.- Returns:
- The truth value determining if the specified
Keyboard.Key
type is currently pressed by the user. - Throws:
NullPointerException
- If the suppliedKeyboard.Key
is null, useKeyboard.Key.NONE
instead to check if no key is currently pressed.
-