Package swingtree.input
Enum Class Keyboard.Key
- All Implemented Interfaces:
Serializable
,Comparable<Keyboard.Key>
,Constable
- Enclosing class:
Keyboard
This enum represents all the keys on the keyboard which can be queried for their current state.
This is a mapping of the
KeyEvent
constants to a more readable and type safe enum.-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionConstant for the ALT virtual key.Constant for the BACK_SPACE virtual key.Constant for the CANCEL virtual key.Constant for the CAPS_LOCK virtual key.Constant for the CLEAR virtual key.Constant for the comma key, ","Constant for the CONTROL virtual key.Constant for the non-numpad down arrow key.SeeKeyEvent.VK_DOWN
for the underlying key-code.Constant for the "8" key.Constant for the END virtual key.Constant for the ENTER virtual key.Constant for the equals key, "="Constant for the ESCAPE virtual key.Constant for the "5" key.Constant for the "4" key.Constant for the HOME virtual key.Constant for the non-numpad left arrow key.Constant for the minus key, "-"Constant for the "9" key.This value is used to indicate that the keyCode is unknown.Constant for the "1" key.Constant for the PAGE_DOWN virtual key.Constant for the PAGE_UP virtual key.Constant for the PAUSE virtual key.Constant for the period key, "."Constant for the non-numpad right arrow key.Constant for the semicolon key, ";"Constant for the "7" key.Constant for the SHIFT virtual key.Constant for the "6" key.Constant for the forward slash key, "/"Constant for the SPACE virtual key.Constant for the TAB virtual key.Constant for the "3" key.Constant for the "2" key.Constant for the non-numpad up arrow key.SeeKeyEvent.VK_U
for the underlying key-code.Constant for the "0" key. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionboolean
This method checks if this key is currently pressed on the keyboard by checking if it is in a list of currently pressed keys.static Keyboard.Key
Returns the enum constant of this class with the specified name.static Keyboard.Key[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
NONE
This value is used to indicate that the keyCode is unknown. KEY_TYPED events do not have a keyCode value; this value is used instead. SeeKeyEvent.VK_UNDEFINED
for more information. -
ENTER
Constant for the ENTER virtual key. SeeKeyEvent.VK_ENTER
for the underlying key-code. -
BACK_SPACE
Constant for the BACK_SPACE virtual key. SeeKeyEvent.VK_BACK_SPACE
for the underlying key-code. -
TAB
Constant for the TAB virtual key. SeeKeyEvent.VK_TAB
for the underlying key-code. -
CANCEL
Constant for the CANCEL virtual key. SeeKeyEvent.VK_CANCEL
for the underlying key-code. -
CLEAR
Constant for the CLEAR virtual key. SeeKeyEvent.VK_CLEAR
for the underlying key-code. -
SHIFT
Constant for the SHIFT virtual key. SeeKeyEvent.VK_SHIFT
for the underlying key-code. -
CONTROL
Constant for the CONTROL virtual key. SeeKeyEvent.VK_CONTROL
for the underlying key-code. -
ALT
Constant for the ALT virtual key. SeeKeyEvent.VK_ALT
for the underlying key-code. -
PAUSE
Constant for the PAUSE virtual key. SeeKeyEvent.VK_PAUSE
for the underlying key-code. -
CAPS_LOCK
Constant for the CAPS_LOCK virtual key. SeeKeyEvent.VK_CAPS_LOCK
for the underlying key-code. -
ESCAPE
Constant for the ESCAPE virtual key. SeeKeyEvent.VK_ESCAPE
for the underlying key-code. -
SPACE
Constant for the SPACE virtual key. SeeKeyEvent.VK_SPACE
for the underlying key-code. -
PAGE_UP
Constant for the PAGE_UP virtual key. SeeKeyEvent.VK_PAGE_UP
for the underlying key-code. -
PAGE_DOWN
Constant for the PAGE_DOWN virtual key. SeeKeyEvent.VK_PAGE_DOWN
for the underlying key-code. -
END
Constant for the END virtual key. SeeKeyEvent.VK_END
for the underlying key-code. -
HOME
Constant for the HOME virtual key. SeeKeyEvent.VK_HOME
for the underlying key-code. -
LEFT
Constant for the non-numpad left arrow key. SeeKeyEvent.VK_LEFT
for the underlying key-code.- See Also:
-
UP
Constant for the non-numpad up arrow key.SeeKeyEvent.VK_U
for the underlying key-code.- See Also:
-
RIGHT
Constant for the non-numpad right arrow key. SeeKeyEvent.VK_RIGHT
for the underlying key-code.- See Also:
-
DOWN
Constant for the non-numpad down arrow key.SeeKeyEvent.VK_DOWN
for the underlying key-code.- See Also:
-
COMMA
Constant for the comma key, "," -
MINUS
Constant for the minus key, "-" -
PERIOD
Constant for the period key, "." -
SLASH
Constant for the forward slash key, "/" -
ZERO
Constant for the "0" key. -
ONE
Constant for the "1" key. -
TWO
Constant for the "2" key. -
THREE
Constant for the "3" key. -
FOUR
Constant for the "4" key. -
FIVE
Constant for the "5" key. -
SIX
Constant for the "6" key. -
SEVEN
Constant for the "7" key. -
EIGHT
Constant for the "8" key. -
NINE
Constant for the "9" key. -
SEMICOLON
Constant for the semicolon key, ";" -
EQUALS
Constant for the equals key, "=" -
A
-
B
-
C
-
D
-
E
-
F
-
G
-
H
-
I
-
J
-
K
-
L
-
M
-
N
-
O
-
P
-
Q
-
R
-
S
-
T
-
U
-
V
-
W
-
X
-
Y
-
Z
-
OPEN_BRACKET
-
BACK_SLASH
-
CLOSE_BRACKET
-
NUMPAD_0
-
NUMPAD_1
-
NUMPAD_2
-
NUMPAD_3
-
NUMPAD_4
-
NUMPAD_5
-
NUMPAD_6
-
NUMPAD_7
-
NUMPAD_8
-
NUMPAD_9
-
MULTIPLY
-
ADD
-
SEPARATOR
-
SUBTRACT
-
DECIMAL
-
DIVIDE
-
DELETE
-
NUM_LOCK
-
SCROLL_LOCK
-
F1
-
F2
-
F3
-
F4
-
F5
-
F6
-
F7
-
F8
-
F9
-
F10
-
F11
-
F12
-
F13
-
F14
-
F15
-
F16
-
F17
-
F18
-
F19
-
F20
-
F21
-
F22
-
F23
-
F24
-
PRINTSCREEN
-
INSERT
-
HELP
-
META
-
BACK_QUOTE
-
QUOTE
-
-
Field Details
-
code
public final int code
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-
isPressed
public boolean isPressed()This method checks if this key is currently pressed on the keyboard by checking if it is in a list of currently pressed keys.- Returns:
- The truth value determining if this key is currently pressed on the keyboard.
-