从stdin中读取单个字符而不按下输入
问题描述:
如何在不按enter/return的情况下从控制台读取单个字符?从stdin中读取单个字符而不按下输入
在红宝石我只想用:
require 'io/console'
input = STDIN.getch
答
试试这个:
char = STDIN.raw &.read_char
p char
谢谢,非常完美! –