PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

KeyDown

Fired when a Key is pressed, with the passed argument being the key that was pressed.

Notes:

  • Not all keys generate this event. However, you can get around this with a few of the keys, “/” for example, by using the Mouse/KeyUp event.
  • Some keys generate the same string as other keys.
  • It’s possible for the string to be empty (possibly due to “\0” key code).

Parameters

Name Type Default Description

key


Code Samples


Mouse.KeyDown

The below example, assuming that ‘mouse’ was defined, would print the key that was pressed (e.g. “q”) along with the ascii value for that key (e.g. 113).

local function onKeyDown( key )
    print("Key:", key, " Code:", string.byte(key))
end
mouse.KeyDown:Connect(onKeyDown)