Does anyone know how to use the new KeyCode API? It's GetKeysPressed, but I don't know how to use it.
I would like it when the letter V is pressed, then I'll add my own code there.
Thanks, -flor
1 | local uis = game:GetService( "UserInputService" ) |
2 | uis.InputBegan:Connect( function (key,bool) |
3 | if bool = = false then |
4 | if key.KeyCode = = Enum.KeyCode.V then |
5 | --do stuff here |
6 | end |
7 | end |
8 | end ) |
Keep in mind this has to be done from a local script.
01 | local uis = game:GetService( "UserInputService" ) |
02 | uis.InputBegan:Connect( function (key, bool) |
03 | bool = false |
04 | if bool = = false then |
05 | if key.KeyCode = = Enum.KeyCode.V then |
06 | -- do stuff here |
07 | bool = true |
08 | end |
09 | end |
10 | end ) |
Both of ya'll are wrong. This is the correct way,
Here's the link: http://wiki.roblox.com/index.php?title=Keyboard_input
1 | function onKeyPress(inputObject, gameProcessedEvent) |
2 | if inputObject.KeyCode = = Enum.KeyCode.V then |
3 | print ( "V was pressed" ) |
4 | end |
5 | end |
6 |
7 | game:GetService( "UserInputService" ).InputBegan:connect(onKeyPress) |