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/06/13 13:19] shedanieltutorial:keybinds [2020/08/09 19:15] – Add link to example emmanuelmess
Line 10: Line 10:
   * react to the key being pressed   * react to the key being pressed
  
 +
 +See [[https://github.com/FabricMC/fabric/blob/1.16/fabric-key-binding-api-v1/src/testmod/java/net/fabricmc/fabric/test/client/keybinding/KeyBindingsTest.java|here]] for an updated example.
  
 ==== Creating your Keybind ==== ==== Creating your Keybind ====
Line 34: Line 36:
 ==== Configuring your Keybind's Category ==== ==== Configuring your Keybind's Category ====
  
-Fabric will automatically register the keybinding's category on keybinding'registry.+Fabric will automatically register the keybinding's category on keybinding'registration.
  
 ==== Registering your Keybind ==== ==== Registering your Keybind ====
Line 52: Line 54:
  
 <code java> <code java>
-ClientTickCallback.EVENT.register(-> +ClientTickEvents.END_CLIENT_TICK.register(client -> { 
-+    while (keyBinding.wasPressed()) System.out.println("was pressed!");
-    if(keyBinding.isPressed()) System.out.println("was pressed!");+
 }); });
 </code> </code>
      
 Keep note that this is entirely client-side. To have the server respond to a keybind, you'll need to send a custom packet and have the server handle it separately. Keep note that this is entirely client-side. To have the server respond to a keybind, you'll need to send a custom packet and have the server handle it separately.
tutorial/keybinds.txt · Last modified: 2023/12/27 13:14 by 2601:188:cb7c:25a0:19fa:9122:4e5a:fad1