Get line feed with getch in Ruby

拜拜、爱过 提交于 2019-12-12 05:03:14

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!