LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   is certain key pressed at the moment ?? (https://www.linuxquestions.org/questions/programming-9/is-certain-key-pressed-at-the-moment-249903/)

freeborn 11-01-2004 01:38 PM

is certain key pressed at the moment ??
 
hi, guys !!

i'm new to linux programming, and trying to write the tetris game. i know that's useless, but that's the way i can learn c under linux.
i need the way to find out if key is down or not at the moment. i don't need to wait for user input (like scanf() or getch() in ncurses). i just need to know if the key is pressed at the moment. i hope you will help me find the solution. thanks any way ;)

alex.

Hko 11-01-2004 03:34 PM

See here:

http://www.linuxquestions.org/questi...hreadid=102330
http://www.linuxquestions.org/questi...threadid=34027
http://www.linuxquestions.org/questi...hreadid=150615
http://www.linuxquestions.org/questi...hreadid=150067

deiussum 11-01-2004 04:50 PM

Are you using a GUI API? If so which one? For instance, if you were using SDL, there is a function called SDL_GetKeyState() you could use.

In Windows there is an API called GetAsyncKeyState. There is probably something similar in Xlib, but I don't know it offhand.

If you are just creating your tetris game as a text based game instead of as an X game, then you'll probably just want to check the links that Hko provided.

freeborn 11-02-2004 01:55 PM

yep, i'm doing all that in text mode using ncurses. i'm checking the links right now ...

freeborn 11-03-2004 03:13 AM

thanks for those links. finally i used new thread which has a infinite loop to read char from the keyboard using ncurses' getch().


All times are GMT -5. The time now is 06:44 PM.