# Keybinds Source: https://tehoclient.dev/modules/keybinds SDK: 1.0.0 Declare named actions with default keys. They appear in Settings -> Servers under your server's name, where players can rebind them, and presses come back to you. You never need a client mod or a chat command for "open party menu". ## Register ```java teho.keybinds().register("Skyline", Arrays.asList( Keybind.builder("party", "Party menu").key('P').description("Open your party").build(), Keybind.builder("emote", "Emote").key('B').build(), Keybind.builder("ping", "Ping location").key(342).build())); ``` The first argument is the category heading players see. `342` is GLFW's left Alt key code. Registering again replaces the list. | Method | Notes | |---|---| | `builder(id, label)` | Both required. | | `key(char)` | A letter or digit. | | `key(int)` | A GLFW key code, for keys that are not letters or digits. `Keybind.UNBOUND` leaves it unbound. | | `hold(boolean)` | Marks the action as one players hold rather than tap. | | `description(String)` | Shown under the label in settings. | | `controller(String)` | A default controller button. | **Not finished** `controller(String)` and `hold(boolean)` are sent to the client and stored, but the client does not act on them yet: it binds no controller button from them and treats every action the same way. Players on a controller can still bind the action themselves. `registered()` returns what you registered and `clear()` removes them. ## Handle presses ```java @EventHandler public void onKey(TehoKeyEvent event) { if (event.getKeybind().equals("party") && event.isPressed()) { openPartyMenu(event.getPlayer()); } if (event.getKeybind().equals("ping") && !event.isPressed()) { pingLocation(event.getPlayer(), event.getHeldMs()); } } ``` Every action reports both the press and the release, and the release carries how long the key was held. Elsewhere use `TehoListener.onKey(player, keybind, pressed, heldMs)`.