Skip to content

Key bindings

Every menu control is a FiveM key mapping, registered as soon as your resource loads MenuAPI.dll. Keyboard, controller and mouse bindings all show up in the player’s Settings, Key Bindings screen under your resource’s name, and the player can rebind them. Their choice is saved on their own machine, so it sticks between sessions and servers.


Seven actions, each bound once per device that can trigger it.

What it does Keyboard Controller Mouse
Opens and closes the menu M Back / View button, held for 400ms
Moves up one item ↑ D-pad up Scroll wheel up
Moves down one item ↓ D-pad down Scroll wheel down
Moves left on lists and sliders, goes back on anything else ← D-pad left
Moves right on lists and sliders, selects anything else → D-pad right
Selects the highlighted item Enter A / Cross Left click
Goes back one menu, or closes the menu Backspace and Esc B / Circle Right click

Every device has its own binding, for example “Menu up”, “Menu up (controller)” and “Menu up (mouse wheel)”, so rebinding one leaves the others alone. A resource can only set one default per binding, but players can add a secondary binding themselves.

Esc is a second keyboard binding for back, listed as “Menu back (alternate)”. While a menu is open Esc does not open the pause menu, P still does.


public class MyMenus : IScript // BaseScript on Legacy
{
public MyMenus()
{
MenuController.MenuToggleKeyDefault = "F5";
}
}

Set it in your resource’s constructor. MenuAPI registers its key mappings one tick after it starts, so this works whichever script is constructed first. Setting it later has no effect.

The value is a keyboard input mapper parameter id, such as "M", "F5" or "HOME". Empty or null falls back to M. Only the keyboard toggle key has a configurable default.


Controller bindings are ordinary key mappings in the same settings screen. Their defaults are the buttons the menu has always used.

The toggle is a hold: keep Back / View down for 400ms to open the menu, and again to close it. A tap of that button is the game’s own interaction menu. Rebinding the toggle to another button keeps the hold.

Set EnableMenuToggleKeyOnController to false to turn off only the controller toggle.


Left click, right click and both wheel directions are bindings too, so they can be rebound or removed. One wheel notch moves exactly one item, it never speeds up like a held arrow key.

Scrolling the wheel while holding TAB on foot is ignored, so the weapon wheel keeps working. That is the one input MenuAPI still reads from the game’s own controls.


A menu can register keys of its own. They show up in the same settings screen under your resource name and the player can rebind them.

menu.AddKeyBinding(
"toggleitems", // short name, this ends up in the command name
"Example: toggle every item", // what the player reads in their key bindings screen
"K", // the default key
"R1_INDEX", // the default controller button, leave it out for none
MenuKeyPressType.JUST_RELEASED, // when your code runs
(m, b) => m.GetMenuItems().ForEach(item => item.Enabled = !item.Enabled),
"Toggle all"); // set this to also draw an instructional button

The handler only runs while that menu is open. Menus that pass the same name share one key, and the first call’s description and defaults are the ones registered. Full reference on the Menu page.


Each binding is a console command. The names contain your resource’s name in lowercase, so two resources that both ship MenuAPI never clash. The suffix is the device: :pad for controller, :mouse for mouse and :alt for a second keyboard key.

menuapi:<your-resource-name>:toggle
+menuapi:<your-resource-name>:toggle:pad
+menuapi:<your-resource-name>:up
+menuapi:<your-resource-name>:up:pad
menuapi:<your-resource-name>:up:mouse
+menuapi:<your-resource-name>:down
+menuapi:<your-resource-name>:down:pad
menuapi:<your-resource-name>:down:mouse
+menuapi:<your-resource-name>:left
+menuapi:<your-resource-name>:left:pad
+menuapi:<your-resource-name>:right
+menuapi:<your-resource-name>:right:pad
+menuapi:<your-resource-name>:select
+menuapi:<your-resource-name>:select:pad
+menuapi:<your-resource-name>:select:mouse
+menuapi:<your-resource-name>:back
+menuapi:<your-resource-name>:back:pad
+menuapi:<your-resource-name>:back:mouse
+menuapi:<your-resource-name>:back:alt

The toggle commands only exist while EnableMenuToggleKey is true. Keys from AddKeyBinding() follow the same pattern, +menuapi:<your-resource-name>:<name> plus :pad when they have a controller button.

A + marks a hold command: FiveM runs +command on press and -command on release. The wheel commands have no + because a notch is never held.


The select and back hints follow the player’s own bindings, and switch to controller icons as soon as a controller is used.

When the game has no icon for a binding, which is common for controller bindings, the hint shows the icon of the key or button that binding was registered with. Run menuapi:<your-resource-name>:buttons in the F8 console while a menu is open to print every binding, its icon and the default it falls back to.

The text next to the hints, and whether they show, is set per menu. See Instructional buttons.