Minecraft:Key codes
More actions
Template:For This is a list of key codes used by Minecraft:Minecraft, which are used in the Minecraft:options.txt file.
Java Edition
Only keys which can be directly detected by the operating system are able to be bound to game controls - keys such as F Lock<ref>Template:Bug</ref> or Fn typically are not recognizable themselves as keys, and Minecraft and all other computer programs will be oblivious to them in isolation.
Only mouse buttons can have controls be bound to them in the options menu. Mouse movement, vertical scrolling and horizontal scrolling are hardcoded, and their default actions cannot be assigned to other keys or buttons, nor can scrolling or moving the mouse be made to do anything else.
Java Edition does not provide official support for controllers.
Keyboard codes
Keyboard buttons are handled as a signed 32-bit integer, meaning that through editing options.txt, values from Template:Code to Template:Code can be specified without being rejected by the game as invalid. Any keys corresponding to a valid SDL key code will be automatically converted to one of the named keys below.
The displayed names of several keys will change depending on the currently active system keyboard layout. The values displayed in this table assume a standard en-US QWERTY layout. Some keys also have operating system dependent names, which are assigned different rows sharing an ID.
If SDL does not define a specific key as a valid input, it will be set to "Not Bound" if attempting to bind a control to it.Template:Until
If a key is pressed that SDL does not assign a key code to, the game will act as though no key is pressed.Template:Upcoming This is a bug which Mojang have decided not to fix.<ref>Template:Bug</ref>
Unused
Minecraft includes IDs and translation strings for all named SDL3 key IDs, even those which are not present in the key binding files for any supported operating system, and therefore cannot be accessed.
These can be set via modifying Template:Code manually, but will not be triggerable due to the lack of an associated key.
Keys such as Escape may warrant inclusion here. It may also be worth creating a table for accidentally-unassignable keys.
Mouse codes
Mouse buttons are handled as a signed 32-bit integer, meaning that through editing options.txt, values from Template:Code to Template:Code can be specified without being rejected by the game as invalid.<ref>Template:Bug</ref> However, the USB HID specification only permits mouse buttons from 1 to 65535,<ref>https://www.usb.org/sites/default/files/documents/hut1_12v2.pdf</ref> meaning that all negative values and the vast majority of the positive values can never actually be assigned to in-game actions without file editing.
On Linux, mouse buttons up to 48 can be specified (evdev key press events 272 to 319) - it is not known if any supported operating systems support a 49th or higher mouse button as input. The maximum mouse button on macOS is 32,<ref>according to what karabiner-elements allows: https://discord.com/channels/647810384031645728/648555495564509184/1528136787434930358</ref> and the maximum mouse button on Windows is 5.
For the first three mouse buttons, the translation keys match the key IDs; all other buttons follow a generic template.
Bedrock Edition
Keyboard codes
Template:Info needed section Template:Cleanup In Template:BE, keys are stored as the decimal representation of their Windows virtual key code. This also includes platforms other than Windows, where keys are loosely mapped to these key codes.
On Android, the majority of non-basic keys are not recognized, and the Menu key is mapped to unknown (255).
Some numbers are skipped because they are reserved or not assigned. By modifying options.txt, you can force the game to show these numbers (prefixed with "Button"), but they are unobtainable by pressing a key. The virtual key code specification also provides numbers for buttons on the mouse. However, mouse buttons are not stored as those numbers.
Multiple keys can be bound to the same action by separating their key codes with a comma in options.txt. There is not a way to do this in-game. For example, the default value in options.txt for opening the chat is Template:Cd, representing both Template:Key and Template:Key.
Mouse codes
Mouse buttons are represented by negative numbers.
On Android, only 3 buttons are recognized, despite the OS supporting up to 5 buttons.
Controller codes
History
Java Edition
Removed keys
| ID | Displayed name | Physical key or button | Translation key | |
|---|---|---|---|---|
| Template:Code | Template:Btn | UnclearTemplate:Note | Template:Code | |
Notes
References
Minecraft:fr:Codes de touche Minecraft:hu:Billentyűkódok Minecraft:ja:キーコード Minecraft:nl:Toetscodes Minecraft:pt:Códigos de teclas Minecraft:ru:Коды клавиш Minecraft:uk:Коди клавіш Minecraft:zh:键控代码