LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 11-01-2004, 02:38 PM   #1
freeborn
LQ Newbie
 
Registered: Aug 2004
Location: Everett, WA
Distribution: Fedora Core 3
Posts: 15

Rep: Reputation: 0
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.
 
Old 11-01-2004, 05:50 PM   #3
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
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.
 
Old 11-02-2004, 02:55 PM   #4
freeborn
LQ Newbie
 
Registered: Aug 2004
Location: Everett, WA
Distribution: Fedora Core 3
Posts: 15

Original Poster
Rep: Reputation: 0
yep, i'm doing all that in text mode using ncurses. i'm checking the links right now ...
 
Old 11-03-2004, 04:13 AM   #5
freeborn
LQ Newbie
 
Registered: Aug 2004
Location: Everett, WA
Distribution: Fedora Core 3
Posts: 15

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[NLD] kernel: atkbd.c: Unknown key pressed sjacobs Suse/Novell 0 06-24-2005 04:14 AM
RHEL 3 - Keyboard send several chars when key pressed once lmx Red Hat 1 01-30-2005 12:46 AM
Connect Gtk's key event with button pressed? Chowroc Programming 6 12-20-2004 02:52 PM
Unknown key pressed Khang Linux - Newbie 3 10-27-2004 05:12 PM
I am getting a ^H when the backspace key is pressed. The only time that it happens is mlawler Linux - Networking 2 04-29-2004 03:37 AM


All times are GMT -5. The time now is 12:13 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration