Module: RatatuiRuby::Event::Key::Modifier
- Included in:
- RatatuiRuby::Event::Key
- Defined in:
- lib/ratatui_ruby/event/key/modifier.rb
Overview
Methods and logic for modifier keys.
Instance Method Summary collapse
-
#alt? ⇒ Boolean
(also: #option?)
Returns true if ALT is held OR if this is a left_alt/right_alt key event.
-
#ctrl? ⇒ Boolean
(also: #control?)
Returns true if CTRL is held OR if this is a left_control/right_control key event.
-
#hyper? ⇒ Boolean
Returns true if HYPER is held OR if this is a left_hyper/right_hyper key event.
-
#meta? ⇒ Boolean
Returns true if META is held OR if this is a left_meta/right_meta key event.
-
#modifier? ⇒ Boolean
Returns true if this is a modifier key event.
-
#shift? ⇒ Boolean
Returns true if SHIFT is held OR if this is a left_shift/right_shift key event.
-
#super? ⇒ Boolean
(also: #win?, #windows?, #command?, #cmd?, #tux?)
Returns true if SUPER is held OR if this is a left_super/right_super key event.
Instance Method Details
#alt? ⇒ Boolean Also known as: option?
Returns true if ALT is held OR if this is a left_alt/right_alt key event.
22 23 24 |
# File 'lib/ratatui_ruby/event/key/modifier.rb', line 22 def alt? @modifiers.include?("alt") || @code == "left_alt" || @code == "right_alt" end |
#ctrl? ⇒ Boolean Also known as: control?
Returns true if CTRL is held OR if this is a left_control/right_control key event.
14 15 16 |
# File 'lib/ratatui_ruby/event/key/modifier.rb', line 14 def ctrl? @modifiers.include?("ctrl") || @code == "left_control" || @code == "right_control" end |
#hyper? ⇒ Boolean
Returns true if HYPER is held OR if this is a left_hyper/right_hyper key event.
52 53 54 |
# File 'lib/ratatui_ruby/event/key/modifier.rb', line 52 def hyper? @modifiers.include?("hyper") || @code == "left_hyper" || @code == "right_hyper" end |
#meta? ⇒ Boolean
Returns true if META is held OR if this is a left_meta/right_meta key event.
57 58 59 |
# File 'lib/ratatui_ruby/event/key/modifier.rb', line 57 def @modifiers.include?("meta") || @code == "left_meta" || @code == "right_meta" end |
#modifier? ⇒ Boolean
Returns true if this is a modifier key event.
Some applications need to know if an event represents a generic key press or a specific modifier key (like CTRL or ALT) being pressed on its own.
This method identifies if the key event itself is a modifier key.
Example
– SPDX-SnippetBegin SPDX-FileCopyrightText: 2026 Kerrick Long SPDX-License-Identifier: MIT-0 ++
if event.modifier?
# Handle solo modifier key press
end
– SPDX-SnippetEnd ++
82 83 84 |
# File 'lib/ratatui_ruby/event/key/modifier.rb', line 82 def modifier? @kind == :modifier end |
#shift? ⇒ Boolean
Returns true if SHIFT is held OR if this is a left_shift/right_shift key event.
30 31 32 |
# File 'lib/ratatui_ruby/event/key/modifier.rb', line 30 def shift? @modifiers.include?("shift") || @code == "left_shift" || @code == "right_shift" end |
#super? ⇒ Boolean Also known as: win?, windows?, command?, cmd?, tux?
Returns true if SUPER is held OR if this is a left_super/right_super key event. Also responds to platform aliases: win?, command?, cmd?, tux?
36 37 38 |
# File 'lib/ratatui_ruby/event/key/modifier.rb', line 36 def super? @modifiers.include?("super") || @code == "left_super" || @code == "right_super" end |