Class: Cura::Event::KeyDown
Overview
Dispatched when a key’s state changes from up to down.
Instance Attribute Summary collapse
-
#name ⇒ Integer
readonly
Get the key name.
Attributes inherited from Base
Instance Method Summary collapse
-
#character ⇒ nil, String
Get the printable character for the key.
-
#control? ⇒ Boolean
Get whether the key was pressed while holding the control key.
-
#initialize(attributes = {}) ⇒ KeyDown
constructor
A new instance of KeyDown.
-
#printable? ⇒ Boolean
Get whether the key is printable.
Methods inherited from Base
#==, #dispatch, inherited, name, #to_h
Methods included from Attributes::HasAttributes
Constructor Details
#initialize(attributes = {}) ⇒ KeyDown
Returns a new instance of KeyDown.
7 8 9 10 11 12 13 |
# File 'lib/cura/event/key_down.rb', line 7 def initialize(attributes={}) @control = false super raise ArgumentError, "name must be set" if @name.nil? end |
Instance Attribute Details
#name ⇒ Integer
Get the key name.
25 26 27 |
# File 'lib/cura/event/key_down.rb', line 25 def name @name end |
Instance Method Details
#character ⇒ nil, String
Get the printable character for the key.
39 40 41 |
# File 'lib/cura/event/key_down.rb', line 39 def character Key.character_from_name(@name) end |
#control? ⇒ Boolean
Get whether the key was pressed while holding the control key.
18 19 20 |
# File 'lib/cura/event/key_down.rb', line 18 def control? @control end |
#printable? ⇒ Boolean
Get whether the key is printable.
30 31 32 33 34 |
# File 'lib/cura/event/key_down.rb', line 30 def printable? return false if @control Key.name_is_printable?(@name) end |