KeyPressed is an event class which occurs when a key on the keyboard is pressed down.
This class gains key and modifiers readers from the KeyboardEvent mixin module.
It also has string, which is a UTF8 string containing the text character that was generated by the keystroke; if nothing was generated, string will be the empty string, “”.
The string attribute is useful for for taking text input (e.g. in a GUI). It supports UTF8 Unicode characters, and works correctly on many different types of keyboards.
Create a new KeyPressed instance.
|key:||a key symbol for the key that was pressed or released. (Symbol, required)|
|modifiers:||an Array of key symbols for the modifier keys that were active when the event occured. (Array, optional)|
|string:||a String containing the text character that was generated by the keystroke, or “” if nothing was generated. (String, optional)|
# File lib/rubygame/events/keyboard_events.rb, line 95 def initialize( key, modifiers=, string="" ) super( key, modifiers ) @string = string.to_str.dup @string.freeze end