Class: Dommy::KeyboardEvent

Inherits:
Event
  • Object
show all
Defined in:
lib/dommy/event.rb

Instance Attribute Summary

Attributes inherited from Event

#type

Instance Method Summary collapse

Methods inherited from Event

#__js_call__, #__js_set__, #__prepare_for_dispatch__, #__record_path__, #__set_current_target__, #bubbles?, #default_prevented?, #immediate_propagation_stopped?, #init_event, #propagation_stopped?

Constructor Details

#initialize(type, init = nil) ⇒ KeyboardEvent

Returns a new instance of KeyboardEvent.



419
420
421
422
423
424
425
426
# File 'lib/dommy/event.rb', line 419

def initialize(type, init = nil)
  super
  @key = read_init(init, "key").to_s
  @ctrl_key = !!read_init(init, "ctrlKey")
  @shift_key = !!read_init(init, "shiftKey")
  @alt_key = !!read_init(init, "altKey")
  @meta_key = !!read_init(init, "metaKey")
end

Instance Method Details

#__js_get__(key) ⇒ Object



428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
# File 'lib/dommy/event.rb', line 428

def __js_get__(key)
  case key
  when "key"
    @key
  when "ctrlKey"
    @ctrl_key
  when "shiftKey"
    @shift_key
  when "altKey"
    @alt_key
  when "metaKey"
    @meta_key
  else
    super
  end
end