Class: Browser::Event::Keyboard
- Inherits:
-
UI
show all
- Defined in:
- opal/browser/event/keyboard.rb
Defined Under Namespace
Classes: Definition
Constant Summary
collapse
- IE_MAP =
IE 11 at least has different names for those keys.
{
'Down' => 'ArrowDown',
'Up' => 'ArrowUp',
'Left' => 'ArrowLeft',
'Right' => 'ArrowRight',
'Esc' => 'Escape',
'Del' => 'Delete'
}
Instance Attribute Summary
#callback, #on
Class Method Summary
collapse
Instance Method Summary
collapse
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
6
7
8
|
# File 'opal/browser/event/keyboard.rb', line 6
def self.supported?
Browser.supports? 'Event.Keyboard'
end
|
Instance Method Details
109
110
111
|
# File 'opal/browser/event/keyboard.rb', line 109
def char
`#@native.char || #@native.charCode || #{code ? code.chr : nil}`
end
|
105
106
107
|
# File 'opal/browser/event/keyboard.rb', line 105
def code
`#@native.keyCode || #@native.which || nil`
end
|
#down? ⇒ Boolean
115
116
117
|
# File 'opal/browser/event/keyboard.rb', line 115
def down?
name.downcase == 'keydown'
end
|
#key ⇒ Object
Also known as:
to_i
100
101
102
103
|
# File 'opal/browser/event/keyboard.rb', line 100
def key
key = `#@native.key || #@native.keyIdentifier || nil`
IE_MAP[key] || key
end
|
#press? ⇒ Boolean
119
120
121
|
# File 'opal/browser/event/keyboard.rb', line 119
def press?
name.downcase == 'keypress'
end
|
#up? ⇒ Boolean
123
124
125
|
# File 'opal/browser/event/keyboard.rb', line 123
def up?
name.downcase == 'keyup'
end
|