From: gotoken@... (GOTO Kentaro) Date: 2001-01-11T14:52:03+09:00 Subject: [ruby-talk:9108] Re: Grabbing a char from the keyboard... In message "[ruby-talk:9106] Grabbing a char from the keyboard..." on 01/01/11, "Hal E. Fulton" writes: >How does one accept a character from the keyboard >as soon as it is pressed? I often use system('stty raw') on UNIX. E.g,: stty_save = `stty -g`.chomp system("stty raw") begin print "quit by hitting q\r\n" while c = STDIN.getc and c != ?q p [c, c.chr] print "\r" end ensure system "stty", stty_save end >I was hoping for some halfway platform-independent >way... I'm guessing there are not such ways. > I naively tried to set STDIN.sync=false, but it >didn't work (1.6.1 on W2K). Shell's line buffer is under controle of tty. So, you have to change the terminal mode. -- Gotoken