altmp / altv-js-module

JS module for alt:V Multiplayer. Powered by NodeJS & v8
MIT License
55 stars 35 forks source link

Refactor JS utils and add Keybind #194

Closed xxshady closed 2 years ago

xxshady commented 2 years ago

Added alt.Utils.Keybind:

// single keycode
const bind = new alt.Utils.Keybind(71, () => {
  alt.log('pressed g')
})

// two keycodes (similar to two separate keybinds with the same handler)
const bind = new alt.Utils.Keybind([71, 75], () => {
  alt.log('pressed g or h')
})

// What key event to use (keyup or keydown) can be specified explicitly (keyup by default)
const bind = new alt.Utils.Keybind(71, () => {
  alt.log('keydown g')
}, 'keydown')