module Rubygame::Events::KeyboardEvent

KeyboardEvent is a mixin module included in the KeyPressed and KeyReleased classes. It defines the key and modifiers accessors.

Attributes

key[R]
modifiers[R]

Public Class Methods

new( key, modifiers=[] ) click to toggle source

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)

# 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