Also, is there any way to tell how long it is pressed for, and when it is let go?
✓ ANSWER ACCEPTED
How do I know if a key is pressed?
1 answer
✓ Accepted answer
To find how long it is pressed for you would set a variable to tick() in your KeyDown function like so:
mouse= --(However you're getting the mouse)
mouse.KeyDown:connect(function(key)
--Do whatever you want with that key here
pasttime=tick()
end)
Then in your KeyUp function would set another variable to tick() and subtract the pasttime variable from the variable you just set. Example:
mouse.KeyDown:connect(function(key)
--Do whatever you want with that key here
currenttime=tick()
keytime=currenttime-pasttime
end)
The keytime variable would be the time the key is pressed.
1 comment
0
Please accept my answer.
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
Please search the wiki and this site, before asking a question. Here is the wiki page: http://wiki.roblox.com/index.php?title=KeyDown
Here's another, http://wiki.roblox.com/index.php?title=KeyUp
They're deprecated. What's the new version?