从stdin中读取单个字符而不按下输入

问题描述:

如何在不按enter/return的情况下从控制台读取单个字符?从stdin中读取单个字符而不按下输入

在红宝石我只想用:

require 'io/console' 
input = STDIN.getch 

试试这个:

char = STDIN.raw &.read_char 
p char 
+0

谢谢,非常完美! –