How to use KeyCode? I wanted to make a script when you press E the text on the GUI changes
Do not listen to superawesome113. He is wrong. KeyCode
is an Enum specifically designed for keyboards and keyboard input. (Controllers also have KeyCodes, but their KeyCodes are of less priority than keyboard KeyCodes.)
KeyCode
would usually be used with the UserInputService
, a client side only service that is used to receive input (hence its name). For detecting the letter E, that would be Enum.KeyCode.E
.
For using KeyCode
, the UserInputService's InputBegan
event passes two parameters for this, the first being the input received. You can check if that input was keyboard input using the keyboard's UserInputType
Enum. Then you can use input.KeyCode
to find what KeyCode was received.
That's basically how you use KeyCode
.