问题
I have the following code:
require 'io/console'
loop do
character = STDIN.getch
break if character == "\n"
print "*"
end
The code is working, but I have to press the Enter key then another key to break the loop. Why? I have this issue only with the line feed.
来源:https://stackoverflow.com/questions/47232924/get-line-feed-with-getch-in-ruby