Input
local input = game:get('Input')
Input service provides signals to listen to various input events.
Signals
onKeyPress:connect(handler: (event: KeyboardEvent): void): void
Triggered when keyboard key is pressed.
local input = game:get('Input')
input.onKeyPress:connect(function(e)
local key = e.key
local mods = e.mods
end)
Parameters:
event
: Keyboard eventevent.key
: Value of the pressed key. The value is a numeric and is based on GLFW key values.event.mods
: Value of the modifier key (e.g Shift) pressed with the key. The value is a numeric and is based on GLFW modifier flags.
onKeyRelease:connect(handler: (event: KeyboardEvent): void): void
Triggered when keyboard key is released.
local input = game:get('Input')
input.onKeyPress:connect(function(e)
local key = e.key
local mods = e.mods
end)
Parameters:
event
: Keyboard eventevent.key
: Value of the released key. The value is a numeric and is based on GLFW key values.event.mods
: Value of the modifier key (e.g Shift) released with the key. The value is a numeric and is based on GLFW modifier flags.