This is your list:

3 -- Cancel
8 -- Backspace
9 -- Tab
10 -- Enter
12 -- Clear
16 -- Shift
17 -- Ctrl
18 -- Alt
19 -- Pause
20 -- Caps Lock
21 -- Kana
24 -- Final
25 -- Kanji
27 -- Escape
28 -- Convert
29 -- No Convert
30 -- Accept
31 -- Mode Change
32 -- Space
33 -- Page Up
34 -- Page Down
35 -- End
36 -- Home
37 -- Left
38 -- Up
39 -- Right
40 -- Down
44 -- Comma
45 -- Minus
46 -- Period
47 -- Slash
48 -- 0
49 -- 1
50 -- 2
51 -- 3
52 -- 4
53 -- 5
54 -- 6
55 -- 7
56 -- 8
57 -- 9
59 -- Semicolon
61 -- Equals
65 -- A
66 -- B
67 -- C
68 -- D
69 -- E
70 -- F
71 -- G
72 -- H
73 -- I
74 -- J
75 -- K
76 -- L
77 -- M
78 -- N
79 -- O
80 -- P
81 -- Q
82 -- R
83 -- S
84 -- T
85 -- U
86 -- V
87 -- W
88 -- X
89 -- Y
90 -- Z
91 -- Open Bracket
92 -- Back Slash
93 -- Close Bracket
96 -- NumPad-0
97 -- NumPad-1
98 -- NumPad-2
99 -- NumPad-3
100 -- NumPad-4
101 -- NumPad-5
102 -- NumPad-6
103 -- NumPad-7
104 -- NumPad-8
105 -- NumPad-9
106 -- NumPad *
107 -- NumPad +
108 -- NumPad ,
109 -- NumPad -
110 -- NumPad .
111 -- NumPad /
112 -- F1
113 -- F2
114 -- F3
115 -- F4
116 -- F5
117 -- F6
118 -- F7
119 -- F8
120 -- F9
121 -- F10
122 -- F11
123 -- F12
127 -- Delete
128 -- Dead Grave
129 -- Dead Acute
130 -- Dead Circumflex
131 -- Dead Tilde
132 -- Dead Macron
133 -- Dead Breve
134 -- Dead Above Dot
135 -- Dead Diaeresis
136 -- Dead Above Ring
137 -- Dead Double Acute
138 -- Dead Caron
139 -- Dead Cedilla
140 -- Dead Ogonek
141 -- Dead Iota
142 -- Dead Voiced Sound
143 -- Dead Semivoiced Sound
144 -- Num Lock
145 -- Scroll Lock
150 -- Ampersand
151 -- Asterisk
152 -- Double Quote
153 -- Less
154 -- Print Screen
155 -- Insert
156 -- Help
157 -- Meta
160 -- Greater
161 -- Left Brace
162 -- Right Brace
192 -- Back Quote
222 -- Quote
224 -- Up
225 -- Down
226 -- Left
227 -- Right
240 -- Alphanumeric
241 -- Katakana
242 -- Hiragana
243 -- Full-Width
244 -- Half-Width
245 -- Roman Characters
256 -- All Candidates
257 -- Previous Candidate
258 -- Code Input
259 -- Japanese Katakana
260 -- Japanese Hiragana
261 -- Japanese Roman
262 -- Kana Lock
263 -- Input Method On/Off
512 -- At
513 -- Colon
514 -- Circumflex
515 -- Dollar
516 -- Euro
517 -- Exclamation Mark
518 -- Inverted Exclamation Mark
519 -- Left Parenthesis
520 -- Number Sign
521 -- Plus
522 -- Right Parenthesis
523 -- Underscore
524 -- Windows
525 -- Context Menu
61440 -- F13
61441 -- F14
61442 -- F15
61443 -- F16
61444 -- F17
61445 -- F18
61446 -- F19
61447 -- F20
61448 -- F21
61449 -- F22
61450 -- F23
61451 -- F24
65312 -- Compose
65368 -- Begin
65406 -- Alt Graph
65480 -- Stop
65481 -- Again
65482 -- Props
65483 -- Undo
65485 -- Copy
65487 -- Paste
65488 -- Find
65489 -- Cut

I generated it with this plain bruteforce:

import java.awt.event.KeyEvent;                                                               
import java.lang.reflect.Field;                                                               
import java.lang.reflect.Modifier;                                                            
import java.util.*;                                                                           
                                                                                              
public class Test {                                                                           
    public static void main(String[] a) {                                                     
        for(int i = 0; i < 1000000; ++i) {                                                    
            String text = java.awt.event.KeyEvent.getKeyText(i);                              
            if(!text.contains("Unknown keyCode: ")) {                                         
                System.out.println("" + i + " -- " + text);                                   
            }                                                                                 
        }                                                                                     
                                                                                              
    }                                                                                         
}

I have excluded the "unknown" codes.

Answer from radrow on Stack Overflow
Top answer
1 of 5
54

This is your list:

3 -- Cancel
8 -- Backspace
9 -- Tab
10 -- Enter
12 -- Clear
16 -- Shift
17 -- Ctrl
18 -- Alt
19 -- Pause
20 -- Caps Lock
21 -- Kana
24 -- Final
25 -- Kanji
27 -- Escape
28 -- Convert
29 -- No Convert
30 -- Accept
31 -- Mode Change
32 -- Space
33 -- Page Up
34 -- Page Down
35 -- End
36 -- Home
37 -- Left
38 -- Up
39 -- Right
40 -- Down
44 -- Comma
45 -- Minus
46 -- Period
47 -- Slash
48 -- 0
49 -- 1
50 -- 2
51 -- 3
52 -- 4
53 -- 5
54 -- 6
55 -- 7
56 -- 8
57 -- 9
59 -- Semicolon
61 -- Equals
65 -- A
66 -- B
67 -- C
68 -- D
69 -- E
70 -- F
71 -- G
72 -- H
73 -- I
74 -- J
75 -- K
76 -- L
77 -- M
78 -- N
79 -- O
80 -- P
81 -- Q
82 -- R
83 -- S
84 -- T
85 -- U
86 -- V
87 -- W
88 -- X
89 -- Y
90 -- Z
91 -- Open Bracket
92 -- Back Slash
93 -- Close Bracket
96 -- NumPad-0
97 -- NumPad-1
98 -- NumPad-2
99 -- NumPad-3
100 -- NumPad-4
101 -- NumPad-5
102 -- NumPad-6
103 -- NumPad-7
104 -- NumPad-8
105 -- NumPad-9
106 -- NumPad *
107 -- NumPad +
108 -- NumPad ,
109 -- NumPad -
110 -- NumPad .
111 -- NumPad /
112 -- F1
113 -- F2
114 -- F3
115 -- F4
116 -- F5
117 -- F6
118 -- F7
119 -- F8
120 -- F9
121 -- F10
122 -- F11
123 -- F12
127 -- Delete
128 -- Dead Grave
129 -- Dead Acute
130 -- Dead Circumflex
131 -- Dead Tilde
132 -- Dead Macron
133 -- Dead Breve
134 -- Dead Above Dot
135 -- Dead Diaeresis
136 -- Dead Above Ring
137 -- Dead Double Acute
138 -- Dead Caron
139 -- Dead Cedilla
140 -- Dead Ogonek
141 -- Dead Iota
142 -- Dead Voiced Sound
143 -- Dead Semivoiced Sound
144 -- Num Lock
145 -- Scroll Lock
150 -- Ampersand
151 -- Asterisk
152 -- Double Quote
153 -- Less
154 -- Print Screen
155 -- Insert
156 -- Help
157 -- Meta
160 -- Greater
161 -- Left Brace
162 -- Right Brace
192 -- Back Quote
222 -- Quote
224 -- Up
225 -- Down
226 -- Left
227 -- Right
240 -- Alphanumeric
241 -- Katakana
242 -- Hiragana
243 -- Full-Width
244 -- Half-Width
245 -- Roman Characters
256 -- All Candidates
257 -- Previous Candidate
258 -- Code Input
259 -- Japanese Katakana
260 -- Japanese Hiragana
261 -- Japanese Roman
262 -- Kana Lock
263 -- Input Method On/Off
512 -- At
513 -- Colon
514 -- Circumflex
515 -- Dollar
516 -- Euro
517 -- Exclamation Mark
518 -- Inverted Exclamation Mark
519 -- Left Parenthesis
520 -- Number Sign
521 -- Plus
522 -- Right Parenthesis
523 -- Underscore
524 -- Windows
525 -- Context Menu
61440 -- F13
61441 -- F14
61442 -- F15
61443 -- F16
61444 -- F17
61445 -- F18
61446 -- F19
61447 -- F20
61448 -- F21
61449 -- F22
61450 -- F23
61451 -- F24
65312 -- Compose
65368 -- Begin
65406 -- Alt Graph
65480 -- Stop
65481 -- Again
65482 -- Props
65483 -- Undo
65485 -- Copy
65487 -- Paste
65488 -- Find
65489 -- Cut

I generated it with this plain bruteforce:

import java.awt.event.KeyEvent;                                                               
import java.lang.reflect.Field;                                                               
import java.lang.reflect.Modifier;                                                            
import java.util.*;                                                                           
                                                                                              
public class Test {                                                                           
    public static void main(String[] a) {                                                     
        for(int i = 0; i < 1000000; ++i) {                                                    
            String text = java.awt.event.KeyEvent.getKeyText(i);                              
            if(!text.contains("Unknown keyCode: ")) {                                         
                System.out.println("" + i + " -- " + text);                                   
            }                                                                                 
        }                                                                                     
                                                                                              
    }                                                                                         
}

I have excluded the "unknown" codes.

2 of 5
19

KeyEvent class has static fields with these values.

For example, KeyEvent.VK_A represent "A" key.

To get the fields names you can use reflection:

Field[] fields = java.awt.event.KeyEvent.class.getDeclaredFields();
for (Field f : fields) {
    if (Modifier.isStatic(f.getModifiers())) {
        System.out.println(f.getName());
    } 
}
🌐
Oracle
docs.oracle.com › javase › 8 › javafx › api › javafx › scene › input › KeyCode.html
KeyCode (JavaFX 8)
3 weeks ago - public static final KeyCode COMMAND · Constant for the Apple Command key. Since: JavaFX 2.1 · public static final KeyCode SHORTCUT · Constant for the Shortcut key. public static KeyCode[] values() Returns an array containing the constants of this enum type, in the order they are declared.
🌐
Oracle
docs.oracle.com › javase › 7 › docs › api › java › awt › event › KeyEvent.html
KeyEvent (Java Platform SE 7 )
Returns an extended key code for the event. The extended key code is a unique id assigned to a key on the keyboard just like keyCode. However, unlike keyCode, this value depends on the current keyboard layout. For instance, pressing the left topmost letter key in a common English layout produces the same value as keyCode, VK_Q.
🌐
Processing
processing.org › reference › keycode
keyCode / Reference / Processing.org
The keys included in the ASCII specification (BACKSPACE, TAB, ENTER, RETURN, ESC, and DELETE) do not require checking to see if the key is coded; for those keys, you should simply use the key variable directly (and not keyCode). If you're making cross-platform projects, note that the ENTER key is commonly used on PCs and Unix, while the RETURN key is used on Macs. Make sure your program will work on all platforms by checking for both ENTER and RETURN. For those familiar with Java, the values for UP and DOWN are simply shorter versions of Java's KeyEvent.VK_UP and KeyEvent.VK_DOWN.
🌐
Gwtproject
gwtproject.org › javadoc › latest › com › google › gwt › event › dom › client › KeyCodes.html
KeyCodes (GWT Javadoc)
int keyCode = KeyCodes.maybeSwapArrowKeysForRtl(event.getKeyCode(), LocaleInfo.getCurrentLocale().isRTL()); switch (keyCode) { case KeyCodes.KEY_LEFT: ... // start of the line, no special RTL handling break; case KeyCodes.KEY_RIGHT: ... // end of the line, no special RTL handling break; ...
🌐
Oracle
docs.oracle.com › javafx › 2 › api › javafx › scene › input › KeyCode.html
KeyCode (JavaFX 2.2)
java.lang.Enum<KeyCode> ... java.lang.Enum<KeyCode> Set of key codes for KeyEvent objects. clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf ·...
🌐
GitHub
github.com › anseki › drgriffin › blob › master › src › drgriffin › KeyCode.java
drgriffin/src/drgriffin/KeyCode.java at master · anseki/drgriffin
* <code>VK_*</code> from {@link java.awt.event.KeyEvent java.awt.event.KeyEvent} */ @SuppressWarnings({"unused", "WeakerAccess", "SpellCheckingInspection"}) public class KeyCode { · /* Virtual key codes.
Author   anseki
🌐
OpenJFX
openjfx.io › javadoc › 17 › javafx.graphics › javafx › scene › input › KeyCode.html
KeyCode (JavaFX 17)
public static final KeyCode COMMAND · Constant for the Apple Command key. Since: JavaFX 2.1 · public static final KeyCode SHORTCUT · Constant for the Shortcut key. public static KeyCode[] values() Returns an array containing the constants of this enum type, in the order they are declared.
Find elsewhere
🌐
Delft Stack
delftstack.com › home › howto › java › java keycode
How to Use Keycode in Java | Delft Stack
February 2, 2024 - In the output, we observe that the left side of the arrow is the keycode and the right side of the arrow is the text description of the key code. import java.awt.event.KeyEvent; public class JavaKeycodeExample { public static void main(String[] args) { for (int keyCode = 0; keyCode < 50; ++keyCode) { String keyCodeText = KeyEvent.getKeyText(keyCode); if (!keyCodeText.contains("Unknown keyCode")) { System.out.println(keyCode + " ---> " + keyCodeText); } } } }
🌐
Bureau of Economic Geology
beg.utexas.edu › lmod › agi.servlet › doc › detail › java › awt › event › KeyEvent.html
java.awt.event Class KeyEvent
Often, however, characters are produced by series of key presses and key releases, and the mapping from key pressed/released events to key typed events may be n:1 or n:m. No key typed events are generated for keys that don't generate characters (e.g., action keys, modifier keys, etc.). The getKeyChar method always returns a valid Unicode character or CHAR_UNDEFINED. For key pressed and key released events, the getKeyCode method returns the event's keyCode.
🌐
GitHub
github.com › jgneff › javafx-graphics › blob › master › src › javafx.graphics › classes › javafx › scene › input › KeyCode.java
javafx-graphics/src/javafx.graphics/classes/javafx/scene/input/KeyCode.java at master · jgneff/javafx-graphics
* @since JavaFX 2.0 · */ public enum KeyCode { · /** * Constant for the {@code Enter} key. */ ENTER(0x0A, "Enter", KeyCodeClass.WHITESPACE), · /** * Constant for the {@code Backspace} key. */ BACK_SPACE(0x08, "Backspace"), ·
Author   jgneff
🌐
Coderanch
coderanch.com › t › 366583 › java › Key-Events-keys
Key Events / Which keys are which? (Java in General forum at Coderanch)
If you have the api, it is under ... "master list" of standard keyboard codes that are given by e.getKeyChar(), and e.getKeyCode() below?: <pre> public void keyPressed(KeyEvent e) { char keyChar = e.getKeyChar() ; int keyCode = e.getKeyCode() ; </pre> For example, the "Enter" key returns a keyCode of 10 when pressed. The code located at the above url (in case you don't have it) is below. It's an applet found at and returns the codes for what you type in a text field: http://java.sun.com/d...
🌐
B4X
b4x.com › home › forums › b4j - desktop, server and raspberry pi › b4j questions
Java for Send keys | B4X Programming Forum
June 16, 2022 - Sub KeyPressed_Filter (e As Event) Dim jo As JavaObject = e Dim EventType As String = jo.RunMethodJO("getEventType", Null).RunMethod("getName", Null) Log(EventType) Select Case EventType Case "KEY_PRESSED" Dim keycode As String = jo.RunMethod("getCode", Null) Log(keycode) end select end sub
🌐
Google
android.googlesource.com › platform › frameworks › base › + › master › core › java › android › view › KeyEvent.java
core/java/android/view/KeyEvent.java - platform/frameworks/base - Git at Google
Sign in · android / platform / frameworks / base / refs/heads/main / . / core / java / android / view / KeyEvent.java · blob: 38e4e2760d2524fedaefa04b637180c0509fce15 [file] [log] [blame] [edit]
🌐
Android Developers
developer.android.com › api reference › keyevent
KeyEvent | API reference | Android Developers
Skip to main content · English · Deutsch · Español – América Latina · Français · Indonesia · Polski · Português – Brasil · Tiếng Việt · 中文 – 简体
🌐
Minecraft Wiki
minecraft.fandom.com › wiki › Key_codes
Key codes - Minecraft Wiki - Fandom
3 weeks ago - This is a list of key codes used by Minecraft, which are used in configuration files such as the options.txt file in the Minecraft directory. LWJGL supports a maximum of 16 mouse buttons. The Minecraft game settings screen translates button 0 to "Button 1", button 1 to "Button 2", et cetera.
🌐
DaniWeb
daniweb.com › programming › software-development › threads › 313416 › keylistener-keytyped-and-keyevent-getkeycode
java - KeyListener.keyTyped and KeyEvent.getKeyCode [SOLVED] | DaniWeb
No key typed events are generated for keys that don't generate Unicode characters (e.g., action keys, modifier keys, etc.). The getKeyChar method always returns a valid Unicode character or CHAR_UNDEFINED. For key pressed and key released events, the getKeyCode method returns the event's keyCode.
🌐
The Coding Forums
thecodingforums.com › archive › archive › java
KeyEvent for % key? | Java | Coding Forums
December 22, 2008 - Although we were able to provide adequate keyboard mappings for the majority of keys from the PC layout to the IBM terminal equivalent (for many locales), there were a few that simply did not have an associated Java event. For example, IBM terminal keyboards distinguish between the keys at positions that correspond, on a PC, to the left and right shift and left and right ctrl. There may have been others. We finally decided to resort to JNI to get the platform key codes, which of course, meant that we had to provide native code for each platform we supported. We used list resource bundles as a sort of database to map keyboards of various locales into the corresponding IBM terminal keyboard.