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, handlers, handles, #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


49
50
51
# File 'opal/browser/event/keyboard.rb', line 49

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

.supported?Boolean

Returns:

  • (Boolean)

6
7
8
# File 'opal/browser/event/keyboard.rb', line 6

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

Instance Method Details

#charObject


98
99
100
# File 'opal/browser/event/keyboard.rb', line 98

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

#codeObject


94
95
96
# File 'opal/browser/event/keyboard.rb', line 94

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

#down?Boolean

Returns:

  • (Boolean)

104
105
106
# File 'opal/browser/event/keyboard.rb', line 104

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

#keyObject Also known as: to_i


90
91
92
# File 'opal/browser/event/keyboard.rb', line 90

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

#press?Boolean

Returns:

  • (Boolean)

108
109
110
# File 'opal/browser/event/keyboard.rb', line 108

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

#up?Boolean

Returns:

  • (Boolean)

112
113
114
# File 'opal/browser/event/keyboard.rb', line 112

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