Sha256: b7b8bf8aba13e92c7333301d48c03e2a166881ee22dc6f27edc86763a36a3386

Contents?: true

Size: 461 Bytes

Versions: 1

Compression:

Stored size: 461 Bytes

Contents

require "io/console"
require "keyevent/version"

module Keyevent
  CR = "\r"
  LF = "\n"
  DEL = "\u007F"
  EOT = "\u0004"
  ESC = "\e"
  ETX = "\u0003"
  SUB = "\u001A"
  TAB = "\t"

  UP = "\e[A"
  DOWN = "\e[B"
  LEFT = "\e[D"
  RIGHT = "\e[C"
end

module Kernel
  def getkey
    input = STDIN.getch

    if input == Keyevent::ESC
      input << STDIN.read_nonblock(3) rescue nil
      input << STDIN.read_nonblock(2) rescue nil
    end

    input
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
keyevent-0.1.0 lib/keyevent.rb