User Tools

Site Tools


tutorial:keybinds

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
tutorial:keybinds [2020/08/09 20:59] – Updated to new API emmanuelmesstutorial:keybinds [2020/12/05 18:07] – formatting majavah
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 "fabric-key-binding-api-v1":"*" to "depends" in your [[documentation:fabric_mod_json_spec|fabric.mod.json]] file.+This tutorial assumes you have the key bindings API, if not add ''%%"fabric-key-binding-api-v1": "*"%%'' to the ''%%"depends"%%'' block in your [[documentation:fabric_mod_json_spec|fabric.mod.json]] file.
  
 Adding a key-bind is easy. You'll need to: Adding a key-bind is easy. You'll need to:
Line 33: Line 33:
 </code> </code>
  
-If you want a sticky key, add "() -> trueas last parameter.+If you want a sticky key, add ''() -> true'' as last parameter.
      
-GLFW.GLFW_KEY_R can be replaced with whatever key you want the binding to default to. The category is related to how the keybinding is grouped in the settings page.+''GLFW.GLFW_KEY_R'' can be replaced with whatever key you want the binding to default to. The category is related to how the keybinding is grouped in the settings page.
  
 ==== Responding to your Keybind ==== ==== Responding to your Keybind ====
Line 43: Line 43:
 <code java> <code java>
  
-ClientTickCallback.EVENT.register(client -> {+ClientTickEvents.END_CLIENT_TICK.register(client -> {
     while (keyBinding.wasPressed()) {     while (keyBinding.wasPressed()) {
  client.player.sendMessage(new LiteralText("Key 1 was pressed!"), false);  client.player.sendMessage(new LiteralText("Key 1 was pressed!"), false);
tutorial/keybinds.txt · Last modified: 2023/12/27 13:14 by 2601:188:cb7c:25a0:19fa:9122:4e5a:fad1