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.
11 12 13 14 15 16 17 |
# File 'lib/cura/event/key_down.rb', line 11 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.
29 30 31 |
# File 'lib/cura/event/key_down.rb', line 29 def name @name end |
Instance Method Details
#character ⇒ nil, String
Get the printable character for the key.
43 44 45 |
# File 'lib/cura/event/key_down.rb', line 43 def character Key.character_from_name(@name) end |
#control? ⇒ Boolean
Get whether the key was pressed while holding the control key.
22 23 24 |
# File 'lib/cura/event/key_down.rb', line 22 def control? @control end |
#printable? ⇒ Boolean
Get whether the key is printable.
34 35 36 37 38 |
# File 'lib/cura/event/key_down.rb', line 34 def printable? return false if @control Key.name_is_printable?(@name) end |