Module: Rubygame::Events::KeyboardEvent
- Included in:
- KeyPressed, KeyReleased
- Defined in:
- lib/rubygame/events/keyboard_events.rb
Overview
KeyboardEvent is a mixin module included in the KeyPressed and KeyReleased classes. It defines the #key and #modifiers accessors.
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#modifiers ⇒ Object
readonly
Returns the value of attribute modifiers.
Instance Method Summary collapse
-
#initialize(key, modifiers = []) ⇒ Object
Initialize the KeyboardEvent.
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
33 34 35 |
# File 'lib/rubygame/events/keyboard_events.rb', line 33 def key @key end |
#modifiers ⇒ Object (readonly)
Returns the value of attribute modifiers.
33 34 35 |
# File 'lib/rubygame/events/keyboard_events.rb', line 33 def modifiers @modifiers end |
Instance Method Details
#initialize(key, modifiers = []) ⇒ Object
Initialize the KeyboardEvent.
- 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)
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/rubygame/events/keyboard_events.rb', line 45 def initialize( key, modifiers=[] ) unless key.kind_of? Symbol raise ArgumentError, "key must be a :symbol" end @key = key @modifiers = modifiers.to_ary.dup @modifiers.freeze end |