Key::bind: Difference between revisions

From RAGE Multiplayer Wiki
mNo edit summary
No edit summary
Line 1: Line 1:
{{ClientsideJsFunction}}
== Description ==
This function binds the key .
This function binds the key .


Line 8: Line 11:
==Example==
==Example==
This example calling server event.
This example calling server event.
{{ClientSide}}
 
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
// 0x71 is the F2 key code
// 0x71 is the F2 key code

Revision as of 12:31, 21 December 2018

Client-Side
Function

 JavaScript



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.

// 0x71 is the F2 key code
mp.keys.bind(0x71, true, function() {
    mp.events.callRemote('keypress:F2'); // Calling server event "keypress:F2"
    mp.gui.chat.push('F2 key is pressed.');
});

See also