OnKeyDown

From GT-MP
Jump to: navigation, search
OnKeyDown
Client-Side Function
System-users.png Client-Side Javascript.png JavaScript

This event triggers the first time a certain key is pressed, and if held down, it repeats after that.

See onKeyUp for more info on the raised event, and the Keys. list.

If you want to use this to catch game controls, consider using isControlJustPressed instead, which matches up with bindings on both keyboard and gamepad.

Syntax

API.onKeyDown.connect(function callback);

Required Arguments

  • callback: parameter input should be in function type.

Usage example

API.onKeyDown.connect(function (sender, e) {
  if (e.KeyCode === Keys.E) {
    // Do something.
    API.sendNotification('Lorem Ipsum.');
  }
});

References