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
[View source]
51
52
53
|
# File 'opal/browser/event/keyboard.rb', line 51
def self.construct(name, desc)
`new KeyboardEvent(#{name}, #{desc})`
end
|
Instance Method Details
[View source]
111
112
113
|
# File 'opal/browser/event/keyboard.rb', line 111
def char
`#@native.char || #@native.charCode || #{code ? code.chr : nil}`
end
|
[View source]
107
108
109
|
# File 'opal/browser/event/keyboard.rb', line 107
def code
`#@native.keyCode || #@native.which || nil`
end
|
[View source]
117
118
119
|
# File 'opal/browser/event/keyboard.rb', line 117
def down?
name.downcase == 'keydown'
end
|
[View source]
102
103
104
105
|
# File 'opal/browser/event/keyboard.rb', line 102
def key
key = `#@native.key || #@native.keyIdentifier || nil`
IE_MAP[key] || key
end
|
[View source]
121
122
123
|
# File 'opal/browser/event/keyboard.rb', line 121
def press?
name.downcase == 'keypress'
end
|
[View source]
125
126
127
|
# File 'opal/browser/event/keyboard.rb', line 125
def up?
name.downcase == 'keyup'
end
|