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
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › API › KeyboardEvent › code
KeyboardEvent: code property - Web APIs | MDN
The KeyboardEvent.code property represents a physical key on the keyboard (as opposed to the character generated by pressing the key). In other words, this property returns a value that isn't altered by keyboard layout or the state of the modifier keys.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › API › KeyboardEvent › keyCode
KeyboardEvent: keyCode property - Web APIs | MDN
You should avoid using this if possible; it's been deprecated for some time. Instead, you should use KeyboardEvent.code (for the physical key pressed) or KeyboardEvent.key (for the character the key maps to).
🌐
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 · 中文 – 简体
🌐
Toptal
toptal.com › developers › keycode
JavaScript Key Code Event Tool | Toptal®
KeyCode.Info allows users to press any key and instantly get the JavaScript Key or Key Code KeyboardEvent. Check out the Tool and Event List.
🌐
Oracle
docs.oracle.com › javase › 7 › docs › api › java › awt › event › KeyEvent.html
KeyEvent (Java Platform SE 7 )
@Deprecated public KeyEvent(Component source, int id, long when, int modifiers, int keyCode) Deprecated. as of JDK1.1 ... Returns the integer keyCode associated with the key in this event. ... the integer code for an actual key on the keyboard.
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());
    } 
}
🌐
W3Schools
w3schools.com › jsref › event_key_code.asp
KeyboardEvent code Property
The code property returns the key code when a keyboard event occurs.
🌐
Oracle
docs.oracle.com › javase › 8 › javafx › api › javafx › scene › input › KeyEvent.html
KeyEvent (JavaFX 8)
2 weeks ago - They are generated whenever a key is pressed or released, and are the only way to find out about keys that don't generate character input (e.g., action keys, modifier keys, etc.). The key being pressed or released is indicated by the code variable, which contains a virtual key code.
🌐
Keyjs
keyjs.dev
Key.js \ JavaScript KeyboardEvent's key codes & key identifiers
👇 Press any key to see JavaScript e.key, e.code, e.which, e.keyCode and more key codes and characters. Better than keycode.info!
Find elsewhere
🌐
freeCodeCamp
freecodecamp.org › news › javascript-keycode-list-keypress-event-key-codes
JavaScript Keycode List – Keypress Event Key Codes for Enter, Space, Backspace, and More
January 8, 2021 - If you have any issues in accessing the playground above, you can access this tool directly here: https://keyevents.netlify.app/ And you can find the source code of the demo from here: https://github.com/atapas/js-keyevents-demo
🌐
W3Schools
w3schools.com › jsref › event_key_keycode.asp
KeyboardEvent keyCode Property
altKey (Mouse) altKey (Key) animationName bubbles button buttons cancelable charCode clientX clientY code ctrlKey (Mouse) ctrlKey (Key) currentTarget data defaultPrevented deltaX deltaY deltaZ deltaMode detail elapsedTime elapsedTime eventPhase inputType isTrusted key keyCode location metaKey (Mouse) metaKey (Key) newURL oldURL offsetX offsetY pageX pageY persisted propertyName relatedTarget relatedTarget screenX screenY shiftKey (Mouse) shiftKey (Key) target targetTouches timeStamp touches type which (Mouse) which (Key) view HTML Event Methods
🌐
W3C
w3.org › TR › uievents-code
UI Events KeyboardEvent code Values
April 22, 2025 - This specification defines the values for the KeyboardEvent.code attribute, which is defined as part of the UI Events Specification [UIEvents]. The code value contains information about the key event that can be used to identify the physical key being pressed by the user.
🌐
GitHub
github.com › openjdk › jdk › blob › master › src › java.desktop › share › classes › java › awt › event › KeyEvent.java
jdk/src/java.desktop/share/classes/java/awt/event/KeyEvent.java at master · openjdk/jdk
* @deprecated as of JDK1.1; use {@link #KeyEvent(Component, int, long, int, int, char)} instead · * @param source The {@code Component} that originated the event
Author   openjdk
🌐
Bureau of Economic Geology
beg.utexas.edu › lmod › agi.servlet › doc › detail › java › awt › event › KeyEvent.html
java.awt.event Class KeyEvent
The unique value assigned to each of the keys on the keyboard. There is a common set of key codes that can be fired by most keyboards. The symbolic name for a key code should be used rather than the code value itself. ... Constructs a KeyEvent object.
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › api › system.windows.forms.keyeventargs.keycode
KeyEventArgs.KeyCode Property (System.Windows.Forms) | Microsoft Learn
This example assumes // that a ... contected to this event handling method. private: void textBox1_KeyDown( Object^ /*sender*/, System::Windows::Forms::KeyEventArgs^ e ) { // Determine whether the key entered is the F1 ...
🌐
GitHub
gist.github.com › arjunv › 2bbcca9a1a1c127749f8dcb6d36fb0bc
All Android Key Events for usage with adb shell · GitHub
def adb(command): os.system(f"adb shell {command}") class KeyMap: zero = "input keyevent 0" soft_left = "input keyevent 1" soft_right = "input keyevent 2" home = "input keyevent 3" back = "input keyevent 4" call = "input keyevent 5" endcall = "input keyevent 6" zer0 = "input keyevent 7" one = "input keyevent 8" two = "input keyevent 9" three = "input keyevent 10" four = "input keyevent 11" five = "input keyevent 12" six = "input keyevent 13" seven = "input keyevent 14" eight = "input keyevent 15" nine = "input keyevent 16" star = "input keyevent 17" pound = "input keyevent 18" dpad_up = "input
Top answer
1 of 4
5

e is the KeyEvent.

if you want to see the e value, then you can try this

System.out.println(e.getKeyChar());

Creating KeyEvent :

KeyEvent e = new KeyEvent(Component source, int id, long when, int modifiers, int keyCode, char keyChar, int keyLocation);

Example (dunno if this is the right way, but it produce the right output):

Button a = new Button("click");
    KeyEvent e;
    e = new KeyEvent(a, 1, 20, 1, 10, 'a');
    System.out.println(""+e.getKeyChar());
    System.out.println(""+e.getKeyCode());

Here is the all type of KeyEvent parameters

java.​awt.​event.​KeyEvent
@Deprecated public KeyEvent(Component source, int id, long when, int modifiers, int keyCode)
Deprecated. as of JDK1.1

===

java.​awt.​event.​KeyEvent
public KeyEvent(Component source, int id, long when, int modifiers, int keyCode, char keyChar)
Constructs a KeyEvent object.
Note that passing in an invalid id results in unspecified behavior. This method throws an IllegalArgumentException if source is null.
Parameters:
source - the Component that originated the event id - an integer identifying the type of event when - a long integer that specifies the time the event occurred modifiers - the modifier keys down during event (shift, ctrl, alt, meta) Either extended _DOWN_MASK or old _MASK modifiers should be used, but both models should not be mixed in one event. Use of the extended modifiers is preferred. keyCode - the integer code for an actual key, or VK_UNDEFINED (for a key-typed event) keyChar - the Unicode character generated by this event, or CHAR_UNDEFINED (for key-pressed and key-released events which do not map to a valid Unicode character) 
Throws:
IllegalArgumentException - if id is KEY_TYPED and keyChar is CHAR_UNDEFINED; or if id is KEY_TYPED and keyCode is not VK_UNDEFINED IllegalArgumentException - if source is null

===

java.​awt.​event.​KeyEvent
public KeyEvent(Component source, int id, long when, int modifiers, int keyCode, char keyChar, int keyLocation)
2 of 4
2

When using robot, first obtain focus of component to which you add your KeyListener to. Then you can use robot to simulte key presses. As an alternative, you can just use dispatchEvent on component to which your listener is added.

KeyEvent key = new KeyEvent(inputField, KeyEvent.KEY_TYPED, System.currentTimeMillis(), 0, KeyEvent.VK_UNDEFINED, 'Z');
inputField.dispatchEvent(key);

Providing you have:

JInputField InputField = new JInputField();

You can as well create KeyEvent as described above and pass it to keyTyped method of your listener. As for keyPrssed, you can do the same.

🌐
Android Developers
stuff.mit.edu › afs › sipb › project › android › docs › reference › android › view › KeyEvent.html
KeyEvent - Android SDK | Android Developers
The key code, action, repeat count and source will automatically be set to KEYCODE_UNKNOWN, ACTION_MULTIPLE, 0, and SOURCE_KEYBOARD for you. ... Make an exact copy of an existing key event. ... This constructor was deprecated in API level 5. Use changeTimeRepeat(KeyEvent, long, int) instead.