|
Name
|
KeyDown
|
|
Arguments
(in table)
|
Key key
|
|
Return option
|
None
|
Description
Fired when a key is pressed down. If the key is held down, it repeats.
Examples
Foo = function(args)
local message = "Key pressed: "..args.key
Chat:Print(message, Color(255, 255, 255))
end
Events:Subscribe("KeyDown", Foo)
Detecting for specific keys
Foo = function(args)
if args.key == VirtualKey.F7 then
Chat:Print("You pressed the F7 key" , Color(255, 255, 255))
end
end
Events:Subscribe("KeyDown", Foo)
Key does not list all characters. For letters/numbers, you can use the the functions
string.byte or
string.char instead.
Foo = function(args)
if args.key == string.byte("M") then
Chat:Print("You pressed the M key" , Color(255, 255, 255))
end
end
Events:Subscribe("KeyDown", Foo)
Foo = function(args)
if string.char(args.key) == "M" then
Chat:Print("You pressed the M key" , Color(255, 255, 255))
end
end
Events:Subscribe("KeyDown", Foo)