Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 31 Oct 2000 16:56:07 -0600 (CST)
From:      Mike Meyer <mwm@mired.org>
To:        "frank xu" <bsdman@hotmail.com>
Cc:        questions@freebsd.org
Subject:   Re: obtain keyboard stat
Message-ID:  <14847.19975.697534.830730@guru.mired.org>
In-Reply-To: <257105@toto.iv>

next in thread | previous in thread | raw e-mail | index | archive | help
frank xu <bsdman@hotmail.com> types:
> Hi,
>   How can I obtain shift,alt and ctrl key state using curses library under 
> FreeBSD?

Enable mouse events, and ask the user to click a mouse button and read
them from the mouse event (see the curs_mouse man page). Of course,
that doesn't work if the user doesn't have a mouse.

Which is pretty much true for any solution. Curses talks to
*terminals*, which send (and receive) characters. Those keys are used
by some terminals to help construct the characters you read with
wgetch. The terminal your user is on may not have some (or any) of
those keys. For instance, using SSH on a Palm pilot I have no keys; I
send a Control-C by stroking ^ C and hitting the "send" button.

So what you have to do is use wgetch to read the character, then
examine the character to see what is and isn't on. The ctype man page
lists functions you can use to do that (assuming you're writing in
C). The curs_getch man page is also of interest, as it lists things
that getch can return that represent various non-ascii keys on the
keyboard. Finally, alt is usually the high bit (0x80), but not
always. If on, you may need to mask it off and the try the ctype tests
for the others.

	<mike




To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?14847.19975.697534.830730>