Input Class
Description
The Input class provides a simple input system for reading keyboard input in the console. It supports a limited set of keys specified by the KeyCode enum.
Enums
KeyCode
: Represents the supported key codes.
Properties
currentKey: KeyCode
: The currently pressed key.previousKey: KeyCode
: The previously pressed key.
Methods
GetKeyDown(KeyCode keyCode): bool
: Checks if a specific key was pressed down since the last frame.GetKey(KeyCode keyCode): bool
: Checks if a specific key is currently being pressed.
Usage
To use the Input class, you can call its methods to read keyboard input and check for key presses. Here's an example:
// Check if the 'W' key was pressed down since the last frame
if (Input.GetKeyDown(KeyCode.W))
{
// Perform an action
}
// Check if the 'S' key is currently being pressed
if (Input.GetKey(KeyCode.S))
{
// Perform an action
}