Sha256: 705c0ff379af8ecaf458422c184ee965220407d641c84f0295e9bc9cd8de2df8

Contents?: true

Size: 292 Bytes

Versions: 11

Compression:

Stored size: 292 Bytes

Contents

require_relative '../lib/tty-reader'

reader = TTY::Reader.new

puts "Press a key (or Ctrl-X to exit)"

loop do
  print "=> "
  char = reader.read_keypress
  if ?\C-x == char
    puts "Exiting..."
    exit
  else
    puts "#{char.inspect} [#{char.ord}] (hex: #{char.ord.to_s(16)})"
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
pokedex-terminal-0.2.8 vendor/bundle/ruby/2.7.0/gems/tty-reader-0.7.0/examples/keypress.rb
pokedex-terminal-0.2.7 vendor/bundle/ruby/2.7.0/gems/tty-reader-0.7.0/examples/keypress.rb
pokedex-terminal-0.2.6 vendor/bundle/ruby/2.7.0/gems/tty-reader-0.7.0/examples/keypress.rb
pokedex-terminal-0.2.5 vendor/bundle/ruby/2.7.0/gems/tty-reader-0.7.0/examples/keypress.rb
pokedex-terminal-0.2.4 vendor/bundle/ruby/2.7.0/gems/tty-reader-0.7.0/examples/keypress.rb
tty-reader-0.7.0 examples/keypress.rb
tty-reader-0.6.0 examples/keypress.rb
tty-reader-0.5.0 examples/keypress.rb
tty-reader-0.4.0 examples/keypress.rb
tty-reader-0.3.0 examples/keypress.rb
tty-reader-0.2.0 examples/keypress.rb