Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Are there any references to keyboard events?

I'm basically asking for a link (like ROBLOX wiki) about scripting for KeyDown (I think this is what it's called? I really have little to no knowledge to the mouse and keyboard things)

Here are some examples I'm trying to figure out:

  • Basically How to even do it

  • How to make something happen, say you press Q without a tool/hopperbin equipped/selected.

  • How to do it with a tool/hopperbin

I'm not expecting a script or someone to teach me via answer, just a link so I can get started. I have little to no knowledge of this, so anything helps.

1 answer

✓ Accepted answer

Using KeyDown events without having a HopperBin equipped: http://wiki.roblox.com/index.php?title=API:Class/Player/GetMouse

-Edit- An example of using this to access keys would be:

local mouse = game.Players.LocalPlayer:GetMouse()

mouse.KeyDown:connect(function(key)

end)

3 comments

0

A better explanation would be that the KeyDown event works through the mouse itself. Without the use of HopperBins, to get the mouse and access the KeyDown you would use this method.

0

I think to check what key is pressed, I'd do something like if key:lower() == "q" then.... or something with byte?

0

key:lower() == "q" works just fine. Keys have byte codes that you could use in place of where the "q" is.

This discussion is preserved as it was. New answers, comments, and votes are closed.