Re: keyboarding in C :)



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
.



Relevant Pages

  • Re: keyboarding in C :)
    ... It would be sth like this ... 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? ... This is almost identical to what you'd do in Windows, except getcharwould probably be replaced with getch, depending on the compiler. ...
    (comp.unix.bsd.freebsd.misc)
  • Re: ".>>>" is a good idea! (OT, was: Re: do you master list comprehensions?)
    ... but I'd much rather have Pythonwin do this automatically for ... You can copy and paste from a Windows command prompt. ... In the system menu for a command window, ... accessible - in a *command line* window, which is using keyboard input by its nature - you have to ...
    (comp.lang.python)
  • RE: re-setting boot partition
    ... Description of the Windows 2000 Recovery Console ... For a Microsoft Windows XP version of this article, ... MB of hard disk space on your system partition to hold the Cmdcons folder ... Windows NTBoot Console Command Interpreter. ...
    (microsoft.public.win2000.setup_upgrade)
  • RE: Win2000 Upgrade to SP3 Express Setup error.
    ... Start your computer with the Windows Setup floppy disks, ... MB of hard disk space on your system partition to hold the Cmdcons folder ... Windows NTBoot Console Command Interpreter. ... you cannot copy a file from the local hard disk to a floppy disk. ...
    (microsoft.public.win2000.setup_upgrade)
  • Re: gnome-list Digest, Vol 109, Issue 9
    ... You got a blinking command prompt. ... Prior to Mac and Windows, ... gnome3, yet another negative feedback ... DE developers, you have my support. ...
    (GNOME)