I
I
IvanN7772015-09-25 14:40:01
ruby
IvanN777, 2015-09-25 14:40:01

I wanted to write a function for reading the keyboard in Ruby, but it doesn’t understand shift, what’s wrong?

Have a function

def read_char
  STDIN.echo = false
  STDIN.raw!

  input = STDIN.getc.chr
  
  return input
end

She does not understand all the keys.
And how to adapt it, under say 'shift'.
How to track combinations? by timeout?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman Mirilaczvili, 2015-09-25
@IvanN777

line = STDIN.readline # идёт набор символов до нажатия клавиши <Enter>
lines = STDIN.read # идёт набор символов до нажатия <Ctrl-D>
?
zetcode.com/lang/rubytutorial/io

T
TyzhSysAdmin, 2015-09-25
@POS_troi

https://msdn.microsoft.com/en-us/library/aa243025(...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question