Module: Curses::Key

Defined in:
lib/curses_extensions.rb,
lib/curses_color.rb

Overview

Curses::Key

Constant Summary collapse

BS =
8
HT =
9
LF =
10
CR =
13
ESC =
27
SP =
32
DEL =
127
KEY_GROUP =
{
  :backspace => [BS, BACKSPACE, DEL],
  :escape => [ESC, BREAK],
  :space => [SP, HT],
  :enter => [ENTER, LF, CR],
  :printable => (33..126).to_a,
}

Class Method Summary collapse

Class Method Details

.match?(key_type, key_code) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
26
27
28
29
30
31
# File 'lib/curses_extensions.rb', line 23

def match?(key_type, key_code)
  if key_type.is_a?(Array)
    key_type.map{ |type| KEY_GROUP[type].include?(key_code)}.include?(true)
  elsif key_type.is_a?(Symbol)
    KEY_GROUP[key_type].include?(key_code)
  else
    false
  end
end