Skip to content

Keybinds

Loaf edited this page Nov 23, 2021 · 1 revision

Add a key

local keyName = "primary" -- a unique(!) name for this keybind, shown to the user when not using a native GTA helptext method
local keyData = {
    defaultKey = "E", -- the default keybind for this key, unless user changes it themselves
    description = "Keybind for primary actions.", -- the description shown to the user when changing the keybind
}
local added = lib.AddKey(keyName, keyData)

Get a key

local keyName = "primary" -- the key to get
local key = lib.GetKey(keyName)
local keyInstructional = key.instructional -- keyInstructional is in the format ~INPUT_...~ and it will automatically show the key when using GTA helptext methods

Get a keys instructional text

local keyName = "primary" -- the key to get
local keyInstructional = lib.GetInstructional(keyName) -- keyInstructional is in the format ~INPUT_...~ and it will automatically show the key when using GTA helptext methods

Check if a key is pressed

local keyName = "primary" -- the key to check if pressed
local isPressed = lib.IsKeyPressed(keyName) -- check if the key is currently pressed down (true or false)

Check if a key was just released

local keyName = "primary" -- the key to check if pressed
local justReleased = lib.IsKeyJustReleased(keyName) -- check if the key was just released (true or false)

Clone this wiki locally