# CFX::REGISTER_RAW_KEYMAP

- **Hash:** `0x49C1F6DC`
- **Namespace:** CFX
- **Runtime name (Lua/JS):** `RegisterRawKeymap`
- **Side:** client (Cfx runtime native)
- **Name status:** official
- **Documentation:** described with examples
- **URL:** https://natives.borderlinerp.com/natives/CFX/REGISTER_RAW_KEYMAP

## Signature

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

## Parameters

- `keymapName` (`char*`) — A **unique** name that the keymap will be bound to, duplicates will result in the keymap not being registered.
- `onKeyDown` (`func`) — The function to run when the key is being pressed, or `nil`.
- `onKeyUp` (`func`) — The function to run when the key is no longer being pressed, or `nil`.
- `rawKeyIndex` (`int`) — The virtual key to bind this keymap to, see a list [here](https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes)
- `canBeDisabled` (`BOOL`) — If calls to [DISABLE_RAW_KEY_THIS_FRAME](#\_0x8BCF0014) 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

*Source: 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.

```ts
function onStateChange();
```

## Usage

### Lua

```lua
RegisterRawKeymap(keymapName, onKeyDown, onKeyUp, rawKeyIndex, canBeDisabled)

-- always available, by hash
Citizen.InvokeNative(0x49c1f6dc, keymapName, onKeyDown, onKeyUp, rawKeyIndex, canBeDisabled)
```

### JavaScript

```js
RegisterRawKeymap(keymapName, onKeyDown, onKeyUp, rawKeyIndex, canBeDisabled);

// by hash
Citizen.invokeNative('0x49c1f6dc', keymapName, onKeyDown, onKeyUp, rawKeyIndex, canBeDisabled);
```

### C#

```csharp
Function.Call((Hash)0x49c1f6dc, keymapName, onKeyDown, onKeyUp, rawKeyIndex, canBeDisabled);
```

## Examples

*Source: Cfx.re native reference*

```lua
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

- [CFX::REMAP_RAW_KEYMAP](https://natives.borderlinerp.com/natives/CFX/REMAP_RAW_KEYMAP.md) — Remaps the keymap bound to keymapName to newRawKeyIndex Virtual key codes can be found here

*Sources: Cfx.re native reference.*
