RedM Natives

REGISTER_RAW_KEYMAP

Registers a keymap that will be triggered whenever rawKeyIndex is pressed or released.

Hash0x49C1F6DC
Runtime nameRegisterRawKeymap
NamespaceCFX
SideClient
NameOfficial
Docs

Signature

void REGISTER_RAW_KEYMAP(char* keymapName, func onKeyDown, func onKeyUp, int rawKeyIndex, BOOL canBeDisabled);

Parameters

NameTypeDescription
keymapNamechar*

A unique name that the keymap will be bound to, duplicates will result in the keymap not being registered.

onKeyDownfunc

The function to run when the key is being pressed, or nil.

onKeyUpfunc

The function to run when the key is no longer being pressed, or nil.

rawKeyIndexint

The virtual key to bind this keymap to, see a list here

canBeDisabledBOOL

If calls to DISABLE_RAW_KEY_THIS_FRAME will disable this keymap, if a keymap was disabled when the key was pressed down it will still call onKeyUp on release.

Returns void

Description

Cfx.re native reference

Registers a keymap that will be triggered whenever rawKeyIndex is pressed or released.

onKeyUp and onKeyDown will not provide any arguments.

function onStateChange();

Usage

Lua
RegisterRawKeymap(keymapName, onKeyDown, onKeyUp, rawKeyIndex, canBeDisabled)

-- always works, by hash
Citizen.InvokeNative(0x49c1f6dc, keymapName, onKeyDown, onKeyUp, rawKeyIndex, canBeDisabled)
JavaScript and C#
JavaScript
RegisterRawKeymap(keymapName, onKeyDown, onKeyUp, rawKeyIndex, canBeDisabled);

// by hash
Citizen.invokeNative('0x49c1f6dc', keymapName, onKeyDown, onKeyUp, rawKeyIndex, canBeDisabled);
C#
Function.Call((Hash)0x49c1f6dc, keymapName, onKeyDown, onKeyUp, rawKeyIndex, canBeDisabled);

Examples

LUA · Cfx.re native reference
function on_key_up()
	print("key no longer pressed")
end

function on_key_down()
	print("key is pressed")
end

local KEY_E = 69
local canBeDisabled = false


RegisterRawKeymap("our_keymap", on_key_up, on_key_down, KEY_E, canBeDisabled)

See also

Sources

Cfx.re native reference

Something wrong or missing? Contribute a verified note — corrections ship through pull requests.