Keys

SHARED FUNCTIONS

Selection of key related functions.

Key List

The file contains a list of keys which can be used through the functions. If you wish to add any additional keys you can do so here.

local keys = {
    ['enter'] = 191,
    ['escape'] = 322,
    ['backspace'] = 177,
    ['tab'] = 37,
    ['arrowleft'] = 174,
    ['arrowright'] = 175,
    ['arrowup'] = 172,
    ['arrowdown'] = 173,
    ['space'] = 22,
    ['delete'] = 178,
    ['insert'] = 121,
    ['home'] = 213,
    ['end'] = 214,
    ['pageup'] = 10,
    ['pagedown'] = 11,
    ['leftcontrol'] = 36,
    ['leftshift'] = 21,
    ['leftalt'] = 19,
    ['rightcontrol'] = 70,
    ['rightshift'] = 70,
    ['rightalt'] = 70,
    ['numpad0'] = 108,
    ['numpad1'] = 117,
    ['numpad2'] = 118,
    ['numpad3'] = 60,
    ['numpad4'] = 107,
    ['numpad5'] = 110,
    ['numpad6'] = 109,
    ['numpad7'] = 117,
    ['numpad8'] = 111,
    ['numpad9'] = 112,
    ['numpad+'] = 96,
    ['numpad-'] = 97,
    ['numpadenter'] = 191,
    ['numpad.'] = 108,
    ['f1'] = 288,
    ['f2'] = 289,
    ['f3'] = 170,
    ['f4'] = 168,
    ['f5'] = 166,
    ['f6'] = 167,
    ['f7'] = 168,
    ['f8'] = 169,
    ['f9'] = 56,
    ['f10'] = 57,
    ['a'] = 34,
    ['b'] = 29,
    ['c'] = 26,
    ['d'] = 30,
    ['e'] = 46,
    ['f'] = 49,
    ['g'] = 47,
    ['h'] = 74,
    ['i'] = 27,
    ['j'] = 36,
    ['k'] = 311,
    ['l'] = 182,
    ['m'] = 244,
    ['n'] = 249,
    ['o'] = 39,
    ['p'] = 199,
    ['q'] = 44,
    ['r'] = 45,
    ['s'] = 33,
    ['t'] = 245,
    ['u'] = 303,
    ['v'] = 0,
    ['w'] = 32,
    ['x'] = 73,
    ['y'] = 246,
    ['z'] = 20,
    ['mouse1'] = 24,
    ['mouse2'] = 25
}

Functions

get_key

Use the following to retrieve the key code for a given key name.

--- Get key code for a given key name
local key_name = 'enter'

--- Utils object
local key_code = utils.keys.get_key(key_name)
print('Key Code for', key_name, ':', key_code)

--- Direct export
local key_code = exports.boii_utils:get_key(key_name)

get_key_name

Use the following to retrieve the key name by a given key code.

--- Get key name for a given key code
local key_code = 191

--- Utils object
local key_name = utils.keys.get_key_name(key_code)
print('Key Name for code', key_code, ':', key_name)

--- Direct export
local key_name = exports.boii_utils:get_key_name(key_code)

Use the following to print the current key list.

--- Utils object
utils.keys.print_key_list()

--- Direct export
exports.boii_utils:print_key_list()

key_exists

Use the following to check if a key exists in the keys table by name.

--- Check if a key exists
local key_name = 'escape'

--- Utils object
local exists = utils.keys.key_exists(key_name)
print('Does key exist?', key_name, ':', exists)

--- Direct export
local exists = exports.boii_utils:key_exists(key_name)

Last updated