Keys::unbind: Difference between revisions
mNo edit summary |
|||
| (One intermediate revision by one other user not shown) | |||
| Line 13: | Line 13: | ||
{{ClientSide}} | {{ClientSide}} | ||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript"> | ||
function | function handler() { | ||
mp.gui.chat.push("F2 was pressed"); | |||
} | } | ||
function | function toggle_keybind(state) { | ||
state | |||
? mp.keys.bind(0x71, true, handler); /** binds F2 to the handler fn */ | |||
: mp.keys.unbind(0x71, true, handler); /** unbinds the handler from F2 key */ | |||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==See also== | ==See also== | ||
{{ | {{Keys_functions_c}} | ||
Latest revision as of 12:46, 15 January 2025
This function unbinds the key.
Required Arguments
- keycode - Code of key (Hexadecimal).
- keyhold - Unbind the binds with keyhold-value.
Optional Arguments
- handler - Only unbind this handler.
Example
Client-Side
function handler() {
mp.gui.chat.push("F2 was pressed");
}
function toggle_keybind(state) {
state
? mp.keys.bind(0x71, true, handler); /** binds F2 to the handler fn */
: mp.keys.unbind(0x71, true, handler); /** unbinds the handler from F2 key */
}