Created
February 11, 2024 20:08
-
-
Save whynotmax/3834f7a7bc6f10ea2a61990b8eca4635 to your computer and use it in GitHub Desktop.
A simple enum for every KeyCode there is ( java.awt.event.KeyEvent )
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package dev.mzcy.keys; | |
@SuppressWarnings("unused") | |
public enum KeyCode { | |
CANCEL(3), | |
BACKSPACE(8), | |
TAB(9), | |
ENTER(10), | |
CLEAR(12), | |
SHIFT(16), | |
CTRL(17), | |
ALT(18), | |
PAUSE(19), | |
CAPS_LOCK(20), | |
KANA(21), | |
FINAL(24), | |
KANJI(25), | |
ESCAPE(27), | |
CONVERT(28), | |
NO_CONVERT(29), | |
ACCEPT(30), | |
MODE_CHANGE(31), | |
SPACE(32), | |
PAGE_UP(33), | |
PAGE_DOWN(34), | |
END(35), | |
HOME(36), | |
LEFT(37), | |
UP(38), | |
RIGHT(39), | |
DOWN(40), | |
COMMA(44), | |
MINUS(45), | |
PERIOD(46), | |
SLASH(47), | |
NUM_0(48), | |
NUM_1(49), | |
NUM_2(50), | |
NUM_3(51), | |
NUM_4(52), | |
NUM_5(53), | |
NUM_6(54), | |
NUM_7(55), | |
NUM_8(56), | |
NUM_9(57), | |
SEMICOLON(59), | |
EQUALS(61), | |
A(65), | |
B(66), | |
C(67), | |
D(68), | |
E(69), | |
F(70), | |
G(71), | |
H(72), | |
I(73), | |
J(74), | |
K(75), | |
L(76), | |
M(77), | |
N(78), | |
O(79), | |
P(80), | |
Q(81), | |
R(82), | |
S(83), | |
T(84), | |
U(85), | |
V(86), | |
W(87), | |
X(88), | |
Y(89), | |
Z(90), | |
OPEN_BRACKET(91), | |
BACK_SLASH(92), | |
CLOSE_BRACKET(93), | |
NUMPAD_0(96), | |
NUMPAD_1(97), | |
NUMPAD_2(98), | |
NUMPAD_3(99), | |
NUMPAD_4(100), | |
NUMPAD_5(101), | |
NUMPAD_6(102), | |
NUMPAD_7(103), | |
NUMPAD_8(104), | |
NUMPAD_9(105), | |
NUMPAD_MULTIPLY(106), | |
NUMPAD_ADD(107), | |
NUMPAD_COMMA(108), | |
NUMPAD_SUBTRACT(109), | |
NUMPAD_DECIMAL(110), | |
NUMPAD_DIVIDE(111), | |
F1(112), | |
F2(113), | |
F3(114), | |
F4(115), | |
F5(116), | |
F6(117), | |
F7(118), | |
F8(119), | |
F9(120), | |
F10(121), | |
F11(122), | |
F12(123), | |
DELETE(127), | |
DEAD_GRAVE(128), | |
DEAD_ACUTE(129), | |
DEAD_CIRCUMFLEX(130), | |
DEAD_TILDE(131), | |
DEAD_MACRON(132), | |
DEAD_BREVE(133), | |
DEAD_ABOVE_DOT(134), | |
DEAD_DIAERESIS(135), | |
DEAD_ABOVE_RING(136), | |
DEAD_DOUBLE_ACUTE(137), | |
DEAD_CARON(138), | |
DEAD_CEDILLA(139), | |
DEAD_OGONEK(140), | |
DEAD_IOTA(141), | |
DEAD_VOICED_SOUND(142), | |
DEAD_SEMIVOICED_SOUND(143), | |
NUM_LOCK(144), | |
SCROLL_LOCK(145), | |
AMPERSAND(150), | |
ASTERISK(151), | |
DOUBLE_QUOTE(152), | |
LESS(153), | |
PRINT_SCREEN(154), | |
INSERT(155), | |
HELP(156), | |
META(157), | |
GREATER(160), | |
LEFT_BRACE(161), | |
RIGHT_BRACE(162), | |
BACK_QUOTE(192), | |
QUOTE(222), | |
UP_ARROW(224), | |
DOWN_ARROW(225), | |
LEFT_ARROW(226), | |
RIGHT_ARROW(227), | |
ALPHANUMERIC(240), | |
KATAKANA(241), | |
HIRAGANA(242), | |
FULL_WIDTH(243), | |
HALF_WIDTH(244), | |
ROMAN_CHARACTERS(245), | |
ALL_CANDIDATES(256), | |
PREVIOUS_CANDIDATE(257), | |
CODE_INPUT(258), | |
JAPANESE_KATAKANA(259), | |
JAPANESE_HIRAGANA(260), | |
JAPANESE_ROMAN(261), | |
KANA_LOCK(262), | |
INPUT_METHOD_ON_OFF(263), | |
AT(512), | |
COLON(513), | |
CIRCUMFLEX(514), | |
DOLLAR(515), | |
EURO(516), | |
EXCLAMATION_MARK(517), | |
INVERTED_EXCLAMATION_MARK(518), | |
LEFT_PARENTHESIS(519), | |
NUMBER_SIGN(520), | |
PLUS(521), | |
RIGHT_PARENTHESIS(522), | |
UNDERSCORE(523), | |
WINDOWS(524), | |
CONTEXT_MENU(525), | |
F13(61440), | |
F14(61441), | |
F15(61442), | |
F16(61443), | |
F17(61444), | |
F18(61445), | |
F19(61446), | |
F20(61447), | |
F21(61448), | |
F22(61449), | |
F23(61450), | |
F24(61451), | |
COMPOSE(65312), | |
BEGIN(65368), | |
ALT_GRAPH(65406), | |
STOP(65480), | |
AGAIN(65481), | |
PROPS(65482), | |
UNDO(65483), | |
COPY(65485), | |
PASTE(65487), | |
FIND(65488), | |
CUT(65489); | |
private final int value; | |
KeyCode(int value) { | |
this.value = value; | |
} | |
/** | |
* Retrieves the value of the current KeyCode. | |
* | |
* @return the value of the current KeyCode | |
*/ | |
public int getValue() { | |
return value; | |
} | |
/** | |
* Finds and returns the KeyCode associated with the given value. | |
* | |
* @param value the value to search for | |
* @return the KeyCode associated with the given value | |
*/ | |
public static KeyCode fromValue(int value) { | |
for (KeyCode keyCode : values()) { | |
if (keyCode.getValue() == value) { | |
return keyCode; | |
} | |
} | |
throw new IllegalArgumentException("Invalid KeyCode value: " + value); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment