Key::bind: Difference between revisions
mNo edit summary |
mNo edit summary |
||
| (3 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
This function binds the key . | {{ClientsideJsFunction}} | ||
== Description == | |||
This function binds the key. | |||
==Parameters== | ==Parameters== | ||
| Line 8: | Line 11: | ||
==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(0x71, true, | mp.keys.bind(0x71, true, () => { | ||
mp.gui.chat.push("F2 was pressed") | |||
}); | }); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
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")
});