Key::bind

From RAGE Multiplayer Wiki
Revision as of 23:03, 7 January 2021 by Wdoyle2 (talk | contribs) (Ignore - was missing the keycode)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Client-Side
Function

Js.png 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