tutorial:keybinds
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| tutorial:keybinds [2023/10/01 03:26] – Clarify the function of sticky keys haykam | tutorial:keybinds [2025/10/22 16:50] (current) – revert that codeblock cassiancc | ||
|---|---|---|---|
| Line 5: | Line 5: | ||
| Minecraft handles user input from peripherals such as the keyboard & mouse using key-binds. When you press W your character moves forward, and when you press E your inventory opens. Every keybind can also be configured with the settings menu, so you can make your player move with arrow keys instead of WASD if you so desire. | Minecraft handles user input from peripherals such as the keyboard & mouse using key-binds. When you press W your character moves forward, and when you press E your inventory opens. Every keybind can also be configured with the settings menu, so you can make your player move with arrow keys instead of WASD if you so desire. | ||
| - | This tutorial assumes you have the key bindings API, if not add '' | + | This tutorial assumes you have the key bindings API, if not add '' |
| Adding a key-bind is easy. You'll need to: | Adding a key-bind is easy. You'll need to: | ||
| * open or create a Client [[documentation: | * open or create a Client [[documentation: | ||
| + | * create a Keybinding.Category object | ||
| * create a KeyBinding object | * create a KeyBinding object | ||
| * react to the key being pressed | * react to the key being pressed | ||
| - | See [[https:// | + | See [[https:// |
| ==== Preparing an Entrypoint ==== | ==== Preparing an Entrypoint ==== | ||
| Line 41: | Line 42: | ||
| ==== Creating your Keybind ==== | ==== Creating your Keybind ==== | ||
| - | Declare | + | Declare these in an area of your preference: |
| <code java> | <code java> | ||
| private static KeyBinding keyBinding; | private static KeyBinding keyBinding; | ||
| + | private static final KeyBinding.Category CATEGORY = KeyBinding.Category.create(Identifier.of(" | ||
| </ | </ | ||
| - | FabricKeyBinding | + | KeyBindingHelper |
| <code java [enable_line_numbers=" | <code java [enable_line_numbers=" | ||
| Line 54: | Line 56: | ||
| InputUtil.Type.KEYSYM, | InputUtil.Type.KEYSYM, | ||
| GLFW.GLFW_KEY_R, | GLFW.GLFW_KEY_R, | ||
| - | | + | |
| + | | ||
| )); | )); | ||
| </ | </ | ||
| + | |||
| + | On versions older than 1.21.9, you would substitute your Keybinding.Category for the translation key of the keybinding' | ||
| Sticky keys can also be created with '' | Sticky keys can also be created with '' | ||
tutorial/keybinds.1696130783.txt.gz · Last modified: 2023/10/01 03:26 by haykam