Description
The Shift
field is a member of the KeyboardModifiers
enumeration in the Sandbox namespace. It represents the Shift key modifier, which can be used to detect if the Shift key is pressed during keyboard input events.
This enumeration is marked with the FlagsAttribute
, allowing for bitwise combination of its member values. This means you can check for multiple key modifiers at once by combining them using bitwise operations.
Usage
Use the Shift
field to determine if the Shift key is being held down during a keyboard event. This can be useful for implementing features that require Shift key detection, such as multi-selection or shortcut key combinations.
To check if the Shift key is pressed, you can use bitwise operations with the KeyboardModifiers
value obtained from the input event.
Example
// Example of checking if the Shift key is pressed
void OnKeyPress(KeyboardModifiers modifiers)
{
if ((modifiers & KeyboardModifiers.Shift) == KeyboardModifiers.Shift)
{
// Shift key is pressed
// Implement logic for when the Shift key is held down
}
}