module RatatuiRuby::Event::Key::Character
Methods for handling printable characters.
Public Instance Methods
Source
# File lib/ratatui_ruby/event/key/character.rb, line 47 def char text? ? @code : nil end
Returns the key as a printable character (if applicable).
- Printable Characters
-
Returns the character itself (e.g.,
"a","1"," "). - Special Keys
-
Returns
nil(e.g.,"enter","up","f1").RatatuiRuby::Event::Key.new(code: “a”).char # => “a”RatatuiRuby::Event::Key.new(code: “enter”).char # => nil
Source
# File lib/ratatui_ruby/event/key/character.rb, line 26 def text? @code.length == 1 end
Returns true if the key represents a single printable character.
RatatuiRuby::Event::Key.new(code: "a").text? # => true RatatuiRuby::Event::Key.new(code: "enter").text? # => false RatatuiRuby::Event::Key.new(code: "space").text? # => false ("space" is not 1 char, " " is)