Module: Zif::KeyPressable
- Included in:
- UI::Input
- Defined in:
- lib/zif/key_pressable.rb
Overview
A mixin to allow compatibility with Services::InputService
Set key down handler attributes #on_key_down to Lambdas accepting the key
argument to do something with this object when keyboard events happen.
Instance Attribute Summary collapse
-
#on_key_down ⇒ Lambda
Called when the key is pressed down.
Instance Method Summary collapse
Instance Attribute Details
#on_key_down ⇒ Lambda
Returns Called when the key is pressed down. Called with the key
that was pressed.
9 10 11 |
# File 'lib/zif/key_pressable.rb', line 9 def on_key_down @on_key_down end |
Instance Method Details
#handle_key(text_key, all_keys) ⇒ Object
Returns nil.
14 15 16 17 |
# File 'lib/zif/key_pressable.rb', line 14 def handle_key(text_key, all_keys) # puts "KeyPressable: handle_key?: #{text_key} :#{all_keys}" on_key_down&.call(text_key, all_keys) end |