Re: keyboarding in C :)
- From: Grant Edwards <grante@xxxxxxxx>
- Date: Thu, 20 Apr 2006 19:16:08 -0000
On 2006-04-20, The Other Guy <tog@xxxxxxxxx> wrote:
I want to write simple app that do some thing acoording to which key was
pressed. It would be sth like this
switch(some_thing)
case (code1) :
do_sth
case (code2) :
do_else
The only problem is i know how to do it in windows (which structure holds
messages from keyboard) and i do not know how to do this in FreeBSD/UNIX.
I would be very happy if someone throw me a link to page that covers this
problem.
Are you simply wanting to do this from a command line tool, or are you
trying to handle keyboard input using one of the GUI toolkits etc?
For a command-line based application, you can just do this...
switch(getchar()) {
case 'a':
// Something
break;
case 'b':
// Something
break;
default:
// Something
break;
}
This is almost identical to what you'd do in Windows, except getchar()
would probably be replaced with getch(), depending on the compiler.
He may want to put the tty into raw mode in order to disable
line-buffering.
--
Grant Edwards grante Yow! This is PLEASANT!
at
visi.com
.
- References:
- keyboarding in C :)
- From: Rumba Dancer
- Re: keyboarding in C :)
- From: The Other Guy
- keyboarding in C :)
- Prev by Date: Re: keyboarding in C :)
- Next by Date: Re: keyboarding in C :)
- Previous by thread: Re: keyboarding in C :)
- Next by thread: Re: keyboarding in C :)
- Index(es):
Relevant Pages
|