Key::bind: Difference between revisions
No edit summary |
mNo edit summary |
||
| (15 intermediate revisions by 8 users not shown) | |||
| Line 1: | Line 1: | ||
This function binds the key . | {{ClientsideJsFunction}} | ||
== Description == | |||
This function binds the key. | |||
==Parameters== | ==Parameters== | ||
* '''keycode''' - code of key | * '''keycode''' - hexadecimal code of [https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731 key]. | ||
* ''' | * '''keydown/keyup''' - true trigges on keydown, false triggers on keyup (bool) | ||
* '''handler''' - function-handler. | * '''handler''' - function-handler. | ||
==Example== | ==Example== | ||
This example calling server event. | This example calling server event. | ||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript"> | ||
// | /** binds F2 to this inline arrow function */ | ||
mp.keys.bind( | mp.keys.bind(0x71, true, () => { | ||
mp.gui.chat.push("F2 was pressed") | |||
}); | }); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==See also== | ==See also== | ||
{{ | {{Keys_functions_c}} | ||
Latest revision as of 12:48, 15 January 2025
Client-Side Function
Description
This function binds the key.
Parameters
- keycode - hexadecimal code of key.
- keydown/keyup - true trigges on keydown, false triggers on keyup (bool)
- handler - function-handler.
Example
This example calling server event.
/** binds F2 to this inline arrow function */
mp.keys.bind(0x71, true, () => {
mp.gui.chat.push("F2 was pressed")
});