Minecraft:Key codes: Difference between revisions
More actions
Sync: updated from Minecraft |
Sync: updated from Minecraft |
||
| Line 1,609: | Line 1,609: | ||
{{info needed section|In the lang files there are translation strings for each translatable keycode that is a shortened version (e.g. PgUp instead of PAGE UP). Figure out if these ever appear in the game and, if they do, add a column for them.}} | {{info needed section|In the lang files there are translation strings for each translatable keycode that is a shortened version (e.g. PgUp instead of PAGE UP). Figure out if these ever appear in the game and, if they do, add a column for them.}} | ||
{{cleanup|section=1|for differing operating systems (e.g. things involving the command key), implement something similar to what is seen with the Java Edition keyboard table above: make the key ID span multiple rows (rowspan 2), and have sub-rows per operating system}} | {{cleanup|section=1|for differing operating systems (e.g. things involving the command key), implement something similar to what is seen with the Java Edition keyboard table above: make the key ID span multiple rows (rowspan 2), and have sub-rows per operating system}} | ||
In {{BE}}, keys are stored as the decimal representation of their [https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes Windows virtual key code]. This also includes platforms other than Windows, where keys are loosely mapped to these | In {{BE}}, keys are stored as the decimal representation of their [https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes 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). | 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. | Some numbers are skipped because they are reserved or not assigned. By modifying <samp>options.txt</samp>, 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 <samp>options.txt</samp>. There is not a way to do this in-game. For example, the default value in <samp>options.txt</samp> for opening the chat is {{cd|84,13}}, representing both {{key|T}} and {{key|Return}}. | |||
{| class="wikitable" data-description="Keyboard button IDs" style="margin-left:auto; margin-right:auto; text-align:center" | {| class="wikitable" data-description="Keyboard button IDs" style="margin-left:auto; margin-right:auto; text-align:center" | ||
! ID | ! ID | ||
| Line 1,649: | Line 1,649: | ||
! {{code|13}} | ! {{code|13}} | ||
| {{btn|RETURN|be=1}} | | {{btn|RETURN|be=1}} | ||
| {{key|Return}} | | {{key|Return}} / {{key|Numpad Enter}} | ||
| {{code|keyboard.keyName.return}} | | {{code|keyboard.keyName.return}} | ||
|- | |- | ||
Revision as of 11:11, 21 September 2026
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.
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:键控代码