I can't seem to find them.
What are the ASCII values for arrow keys?
3 answers
Here's the wiki page for special characters: http://wiki.roblox.com/index.php?title=Special_Characters. The arrows are ASCII values 17-20.
We can find them ourselves using a really simple script. No need to look them up at all.
local m = game.Players.LocalPlayer:GetMouse();
m.KeyDown:connect(function(e)
print(e:byte());
end
);
Left: 20
Down: 18
Right: 19
Up: 17
1 comment
This also works too.
While this doesn't answer your question, I would suggest that you use the UserInputService to bind keys to functions, rather than connecting the KeyDown event. You'll never run into problems like this (having to look up specific keycodes), and you'll never have to worry about keys sharing keycodes, or certain keycodes for KeyUp or KeyDown being reserved by ROBLOX.
This runs in a LocalScript:
local uis = Game:GetService("UserInputService")
uis.InputBegan:connect(function(inst) --KeyDown
if inst.UserInputType == Enum.UserInputType.Keyboard then
if inst.KeyCode == Enum.KeyCode.Left then
print("Left arrow pressed")
elseif inst.KeyCode == Enum.KeyCode.Right then
print("Right arrow pressed")
end --And so on.
end
end
uis.InputEnded:connect(function(inst) --KeyUp
--you get the idea
end
Those two events also fire on mouse clicks, and there is a third, InputChanged that fires when the mouse moves, or the scrollwheel is scrolled.
Additionally, there are events in the UserInputService that allow you to bind functions to Touch controls, such as for an iPad.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Thank you.