Class: Tea::Kbd::Down
Overview
Event generated when a key is pressed down.
key
-
Physical key that was pressed, as a symbol (see key reference).
mods
-
Hash of the active key modifiers. Values are
true
orfalse
, and the keys can be::L_SHIFT
,:R_SHIFT
,:L_CTRL
,:R_CTRL
,:L_ALT
,:R_ALT
,:NUM_LOCK
,:CAPS_LOCK
,:ALT_GR
. Also,:SHIFT
,:CTRL
and:ALT
are provided for convenience, and Tea key constants with the same names can be used instead. char
-
String character generated by that key and those modifiers. With Ruby >= 1.9, the encoding of this character is UTF-8, otherwise it varies with the running environment.
Instance Attribute Summary collapse
-
#char ⇒ Object
readonly
Returns the value of attribute char.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#mods ⇒ Object
readonly
Returns the value of attribute mods.
Instance Method Summary collapse
-
#initialize(sdl_event) ⇒ Down
constructor
A new instance of Down.
Methods inherited from Event
Constructor Details
#initialize(sdl_event) ⇒ Down
Returns a new instance of Down.
198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
# File 'lib/tea/m_event_keyboard.rb', line 198 def initialize(sdl_event) @key = sdl_keysym_to_key(sdl_event.sym) @mods = sdl_keymod_to_mods(sdl_event.mod) if sdl_event.unicode != 0 unicode_field = "%c" # Ruby 1.9 uses UTF-8 Unicode encoding. Otherwise, who knows how # Unicode code points are interpreted? unicode_field = unicode_field.encode('utf-8') if RUBY_1_9 @char = unicode_field % sdl_event.unicode else @char = '' end end |
Instance Attribute Details
#char ⇒ Object (readonly)
Returns the value of attribute char.
197 198 199 |
# File 'lib/tea/m_event_keyboard.rb', line 197 def char @char end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
197 198 199 |
# File 'lib/tea/m_event_keyboard.rb', line 197 def key @key end |
#mods ⇒ Object (readonly)
Returns the value of attribute mods.
197 198 199 |
# File 'lib/tea/m_event_keyboard.rb', line 197 def mods @mods end |