TypeScript
Control
Client

Client

control.disable

disable a keybind's functionality

control.disable(key: Bind): boolean

Parameters

  • key: The keybind to disable

control.onDisable

override a keybind's functionality (disable it) with a callback (allow what gets passed only)

control.onDisable(key: Bind, callback: () => void): boolean

Parameters

  • key: The keybind's events to disable and to detect from
  • callback: The function to run when the disabled keybind gets pressed

control.onHold

function that runs when a keybind gets held

control.onHold(key: Bind, callback: () => void): boolean

Parameters

  • key: The keybind to hold
  • callback: The function to run when the keybind gets held

control.onPress

function that runs when a keybind gets pressed

control.onPress(key: Bind, callback: () => void): boolean

Parameters

  • key: The keybind to press
  • callback: The function to run when the keybind gets pressed

control.onRelease

function that runs when a keybind is not being held

control.onRelease(key: Bind, callback: () => void): boolean

Parameters

  • key: The keybind to detect the release from
  • callback: The function to run when the keybind is not being held

control.onReleased

function that runs when a keybind gets released

control.onReleased(key: Bind, callback: () => void): boolean

Parameters

  • key: The keybind to detect the release from
  • callback: The function to run when the keybind gets released

Returns

  • success: whether the keybind was successfully registered or not

Examples

import { control } from '@trippler/tr_lib/client'
 
control.disable('ESC') /* true */
 
control.onDisable('ESC', () => {
  console.log('Disabled key got pressed')
}) /* true */
 
control.onHold('ESC', () => {
  console.log('the key is being held')
}) /* true */
 
control.onPress('ESC', () => {
  console.log('the key got pressed')
}) /* true */
 
control.onRelease('ESC', () => {
  console.log('the key is not being held')
}) /* true */
 
control.onReleased('ESC', () => {
  console.log('the key got released')
}) /* true */