Class: Browser::Event::Keyboard

Inherits:
UI show all
Defined in:
opal/browser/event/keyboard.rb

Defined Under Namespace

Classes: Definition

Instance Attribute Summary

Attributes inherited from Browser::Event

#callback, #on

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Browser::Event

aliases, #arguments, #arguments=, class_for, create, #initialize, #name, name_for, new, #off, #prevent, #prevented?, #stop, #stop!, #stopped?, #target

Constructor Details

This class inherits a constructor from Browser::Event

Class Method Details

.construct(name, desc) ⇒ Object



47
48
49
# File 'opal/browser/event/keyboard.rb', line 47

def self.construct(name, desc)
  `new KeyboardEvent(#{name}, #{desc})`
end

.supported?Boolean

Returns:

  • (Boolean)


4
5
6
# File 'opal/browser/event/keyboard.rb', line 4

def self.supported?
  Browser.supports? 'Event.Keyboard'
end

Instance Method Details

#charObject



96
97
98
# File 'opal/browser/event/keyboard.rb', line 96

def char
  `#@native.char || #@native.charCode || #{code ? code.chr : nil}`
end

#codeObject



92
93
94
# File 'opal/browser/event/keyboard.rb', line 92

def code
  `#@native.keyCode || #@native.which || nil`
end

#down?Boolean

Returns:

  • (Boolean)


102
103
104
# File 'opal/browser/event/keyboard.rb', line 102

def down?
  name.downcase == 'keydown'
end

#keyObject Also known as: to_i



88
89
90
# File 'opal/browser/event/keyboard.rb', line 88

def key
  `#@native.key || #@native.keyIdentifier || nil`
end

#press?Boolean

Returns:

  • (Boolean)


106
107
108
# File 'opal/browser/event/keyboard.rb', line 106

def press?
  name.downcase == 'keypress'
end

#up?Boolean

Returns:

  • (Boolean)


110
111
112
# File 'opal/browser/event/keyboard.rb', line 110

def up?
  name.downcase == 'keyup'
end