[FREE][STANDALONE] Keybind creator resource for FiveM

Keybind resource for FiveM

Creating custom keybinds for fivem made easy.


This resource allows you to create dynamic keybinds that users can customize for their own tastes.

This is able because of the relatively new RegisterKeyMapping feature in fivem which allows us to bind commands to certain keys.

These keys will show up under the keybind settings in the native GTAV settings menu.

Usage

Using the resource


This resource uses exports to handle the registering of keybinds.

All examples below will be in LUA but they can be used in JavaScript as well.

Creating a simple keybind:


    exports.keybinds:RegisterKeybind(name, description, key, func)

  • Name: The name of the keybind, later needed to toggle it on/off

  • description: The description of the keybind. This will show up in the settings.

  • key: A key to be used as default. You can get the key ids from this website: KEYBOARD - Cfx.re Docs

  • func: This is the function that will be played on the press of the keybind

Creating a keybind that needs to be held down:


    exports.keybinds:RegisterHoldKeybind(name, description, key, func, delay)

  • Name: The name of the keybind, later needed to toggle it on/off

  • description: The description of the keybind. This will show up in the settings.

  • key: A key to be used as default. You can get the key ids from this website: KEYBOARD - Cfx.re Docs

  • func: This is the function that will be played when the keybind is held down

  • delay: This sets the frequency of the function playing while the keybind is held down (miliseconds)

Note: The function always plays first, so when you press the keybind once, the function still plays

Creating a two way keybind:


    exports.keybinds:RegisterTwoWayKeybind(name, description, key, func1, func2)

  • Name: The name of the keybind, later needed to toggle it on/off

  • description: The description of the keybind. This will show up in the settings.

  • key: A key to be used as default. You can get the key ids from this website: KEYBOARD - Cfx.re Docs

  • func1: This is the function that will be played when the keybind is pressed

  • func2: This is the function that will be played when the keybind is released

Toggling the keybinds:


    exports.keybinds:ToggleKeybind(name, state)

  • Name: The name of the keybind that you want to toggle

  • State: true means the keybind doesn’t do anything, false means the keybind is active

HUN description

Keybind resource a Fivem-hez

Billentyűparancsok készítése leegyszerűsítve


Ezzel a resource-al képes vagy olyan billentyűparancsokat létrehozni amelyet a felhasználók könnyedén tudnak változtatni saját izlésük szerint

Ez a viszonylag új RegisterKeyMapping function miatt jöhetett létre, amely képes parancsokhoz billentyűparancsot rendelni.

Az összes billentyűparancs amit ezzel készítesz a GTAV-s beállításokon belül megtalálható és állítható lesz.

Felhasználás


Ez a resource exportokat használ a billentyűparancsok létrehozására

A lenti pélák mind LUA nyelven vannak feltüntetve, viszont JavaScript-ben is müködnek.

Egyszerű billentyűparancs készítése:


    exports.keybinds:RegisterKeybind(name, description, key, func)

  • Name: A billentyűparancs neve. Késöbb a kikapcsolásához fog kelleni.

  • description: A billentyűparancs leírása. Ez fog megjelenni a beállításokban is.

  • key: Az alapértelmezett billenytű. A következő weboldalon megtalálod az összes lehetőséget: KEYBOARD - Cfx.re Docs

  • func: A kód ami le fog játszódni amikor lenyomják a billentyűparancs-ot. (Egy function)

Lenyomva tartható billentyűparancs készítése:


    exports.keybinds:RegisterHoldKeybind(name, description, key, func, delay)

  • Name: A billentyűparancs neve. Késöbb a kikapcsolásához fog kelleni.

  • description: A billentyűparancs leírása. Ez fog megjelenni a beállításokban is.

  • key: Az alapértelmezett billenytű. A következő weboldalon megtalálod az összes lehetőséget: KEYBOARD - Cfx.re Docs

  • func: A kód ami le fog játszódni amikor lenyomják a billentyűparancs-ot. (Egy function)

  • delay: Mennyi idő teljen el kettő lejátszott kódsor között (milisec)

Note: A function mindig először játszódik le, és utána várokozik, így elég ha a felhasználó egyszer lenyomja, akkor is lejátszódik.

Kétirányú billentyűparancs készítése:


    exports.keybinds:RegisterTwoWayKeybind(name, description, key, func1, func2)

  • Name: A billentyűparancs neve. Késöbb a kikapcsolásához fog kelleni.

  • description: A billentyűparancs leírása. Ez fog megjelenni a beállításokban is.

  • key: Az alapértelmezett billenytű. A következő weboldalon megtalálod az összes lehetőséget: KEYBOARD - Cfx.re Docs

  • func1: Kód amely lejátszódik amikor lenyomja a felhasználó a billentyűt

  • func2: Kód amely lejátszódik amikor felengedi a felhasználó a billentyűt

Billentyűparancsok kapcsolása:


    exports.keybinds:ToggleKeybind(name, state)

  • Name: A billentyűparancs neve amelyet kapcsolni szeretnél

  • State: true azt jelenti hogy a billentyűparancs nem csinál semmit, false azt jelenti hogy a billentyűparancs aktív

Download

Github: GitHub - 0324bence/FiveM-Keybinds: A resource that allows you to create custom keybinds
Direct download(zip): keybinds.zip (3.1 KB)

11 Likes

nicee

1 Like

Nice release!

Maybe I don’t understand, but joypad users can edit keys as they need?

I am not sure, as all of these keybinds will be declared with the keyboard mapper. But I did not test it on controllers, so maybe they can

this is such a good resource

If works its amazing, for example controller users can set their own key for some functions

I did a test just now, and you cannot change the keybind to controller inputs. But if you really need it, you can easily modify the resource

1 Like

I will try it and will share with you if I can handle it

Nice! Thank you!!

Hey, very nice release!!

Just a quick question. If the players changes a keybind, will the changed keybind be saved?

Yes it will be saved.

1 Like

Hi, nice release but could you make an example of using this script? I have problem cuz i don’t really know how to write function which works with it.

Hi. I will write an example as soon as I can. It is not that hard. When I tested it everything that worked in a client side chat command works in the keybinds too

Possible to make this worj with rp-radio for mumble-voip? I cant figure it out

where do i put this?
client or server