getch

How to get a single character in ruby without pressing enter

How can I get a single keyboard character from the terminal with ruby without pressing enter? I tried Curses::getch, but that didn't really work for me. ...

equivalent to getch(), mac/linux crash

Hey guys. So I am using getch() and my app crashes instantly. Including when doing: int main() { getch(); } I can't find the link but supposedly the problem is, it needs to turn off buffering or something strange along those lines and I still want cout to work along with cross platform code. I was told to use std::cin.get(), but I'd...

Problem with an expect script

Hi, I'm trying to create a script to update a password in a non-interactive way. It's working on my laptop but fails on my server. Both are running the same configuration, using Etch. This is the script: #!/usr/bin/expect -f # Change user passwd set timeout 30 strace 4 set password [lindex $argv 1] set old_password [lindex $argv 2] s...

Non-blocking getch(), ncurses

I'm having some problems getting ncurses' getch() to block. Default operation seems to be non-blocking (or have I missed some initialization)? I would like it to work like getch() in Windows. I have tried various versions of timeout(3000000); nocbreak(); cbreak(); noraw(); etc... (not all at the same time). I would prefer to not (expl...

Reading a single character (getch style) in Python is not working in Unix

Any time I use the recipe at http://code.activestate.com/recipes/134892/ I can't seem to get it working. It always throws the following error: Traceback (most recent call last): ... old_settings = termios.tcgetattr(fd) termios.error: (22, 'Invalid argument) My best thought is that it is because I'm running it in Eclipse so ter...

Problem with kbhit()[and getch()] for Linux.

while(ch != 'q') { printf("looping\n"); sleep(1); if(kbhit()) { ch = readch(); printf("you hit %c\n",ch); } } This code gives me a blocking getch() like functionality. I am trying to use this code to capture up down arrow keys. Added: Trying to capture key codes of up arrow gives me 3 chars 27, 91 and 65. Using i...

Equivalent function to C's "_getch()" in Java?

Hey guys, I was messing around with C/C++ and recently found the _getch() function. I also recently got an invite to Google Wave (amazing, btw), and I wanted to emulate the ability to send messages before you actually hit the enter key. However, I don't know much (anything <.<) about networking in C/C++, while I know a decent amount abo...

Something like getch(), textcolor() and gotoxy() in Ruby.

Hello. I want to use these functions from the conio.c library (Borland) in Ruby, specially getch(). getch() gets a key from the keyboard without press enter. textcolor() changes the color of the text in the terminal. gotoxy() moves the cursor to other position of the terminal. Someone knows the equivalents? Thanks. ...

C++ getch() in perl?

In c++, there is a functio, getch(), which returns the variable of the key you pressed - like enter would be 13. How could I do this in perl? ...

How to implement getch() function of C in Linux?

In turbo c++, we can use getch() function available in conio.h. But in linux, gcc compiler doesn't provide conio.h header file, then how to get functionality of getch() function? ...

Can curses be avoided to get an "any key" getch prompt echoed to a raw_input() call?

I have a command line mini-app written in Python 2.7 that has a "press any key" style prompt, but that responds differently depending on what kind of key the user types. If they type a character, then that character will become the first character of the search query. I don't want the user to have to type a character to indicate "I'm do...

a simple getch() and strcmp problem

I have this simple problem that gets an input from the user using a function then checks if the input is 'equal' to the "password". However, strcmp would never return my desired value, and the culprit is somewhere in my loop that uses getch() to take each character separately and add them to the character array. I found this out by havin...

How do I use pointers in combination with getc?

I have a function getNum(), which gets a number from file and returns it. When I go back into getNum() I have lost the pointer and it starts at the begging of the file again. I'm wondering How do I get the location of where getc is and then go back to that place. I couldn't find how to do this in the manual or in forums. Thank you. #inc...