LinuxQuestions.org
Review your favorite Linux distribution.
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 04-14-2005, 02:03 AM   #1
hpcpg
LQ Newbie
 
Registered: Oct 2003
Location: Czech republic
Distribution: Fedora Core 3
Posts: 15

Rep: Reputation: 0
control, alt, shift in console


Hi.
Does anybody know how can I found out in console whether alt, control or shift is pressed? In ncurses it is possible only for mouse events, but I need it for keyboard events. I looked into Midnight Commander sources, but it uses glib and I don't want to use X libraries in console program. There is also another way to find it out, but I don't understand it:

ioctl(0, TIOCLINUX, &modifiers);

It's only for linux, but it's better than nothing.
First argument should be descriptor (or something like that) to open file, but there is only 0. Is it stdin, stdout or something like that? I ask because it doesn't work for me (it returns -1) so I want to know how to get it working.

I would be very grateful for any way (even nonportable) to find out whether ALT, SHIFT or CONTROL is pressed.

TIA.
 
Old 04-15-2005, 04:37 AM   #2
hpcpg
LQ Newbie
 
Registered: Oct 2003
Location: Czech republic
Distribution: Fedora Core 3
Posts: 15

Original Poster
Rep: Reputation: 0
Nobody knows?
 
Old 04-15-2005, 06:16 AM   #3
ChemicalBurn
LQ Newbie
 
Registered: Feb 2005
Posts: 28

Rep: Reputation: 15
What you can do is change the listener on the console to respond to any hit on the keybord as opposed to the "Enter" button. Did this a long time ago, but forgot how. Google it if anything.
Then you can check what button has been pressed.
Hope this helps, have some work to do. If you dont have an answer later, Ill try to look it up for you after Im done
Good luck
 
Old 04-15-2005, 06:46 AM   #4
hpcpg
LQ Newbie
 
Registered: Oct 2003
Location: Czech republic
Distribution: Fedora Core 3
Posts: 15

Original Poster
Rep: Reputation: 0
Thanks a lot for response. I 'll try google.
 
  


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
Control-Alt-Delete to bring up logoff prompt ocgltd Linux - Software 5 09-16-2005 09:01 PM
changing the keyboard with alt-shift in KDE dvm Linux - Software 3 05-23-2005 04:47 PM
How do you press Ctrl,Alt and shift? littertiger Programming 4 05-17-2005 03:00 AM
Control Alt Delete Restarts Computer, how to fix? PeaceTank Linux - Software 1 02-22-2005 01:00 AM
Console shift-pageup Speek Slackware 2 09-28-2004 09:48 AM


All times are GMT -5. The time now is 10:13 PM.

Main Menu
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