From: Jan-Benedict Glaw <jbglaw@lug-owl.de>
To: linux-c-programming@vger.kernel.org
Subject: Re: Curses and key-up information
Date: Tue, 7 Jan 2003 08:08:10 +0100 [thread overview]
Message-ID: <20030107070810.GD2529@lug-owl.de> (raw)
In-Reply-To: <15897.43047.454804.466506@cerise.nosuchdomain.co.uk>
[-- Attachment #1: Type: text/plain, Size: 1876 bytes --]
On Mon, 2003-01-06 16:00:39 +0000, Glynn Clements <glynn.clements@virgin.net>
wrote in message <15897.43047.454804.466506@cerise.nosuchdomain.co.uk>:
> > I'm writing to write a little curses maze game that involves a lot of key
> > handling, and the most obvious way to handle the control is with a
> > IsKeyDown(char key) type-function. Alas, curses doesn't appear to have one
> > and was wondering is anyone else has found a way around this problem (either
> > within curses, or using ioctl/poll or similar).
>
> It can't be done. The process only receives notification of key
> presses; there is no way to discover when a key is released.
Well, in some special cases, you _can_ get key-up information as well as
key-down notofications. However, this is hackish...
> Bear in mind that Unix terminal I/O was designed for terminals (vt100
> etc) rather than a keyboard which is attached directly. Terminals
> (whether hardware terminals such as the vt100, emulators such as
> xterm, the linux console, telnet etc) simply don't send anything when
> a key is released, so there's no way to detect it.
Some time ago, we had almost the same topic. IIRC I've had posted some
code snipplets at that time.
Basically, as long as you use your console as a real terminal (probably
using some helper library as (n)curses/termcap etc), you don't get
key-{up|down} information, but only "key Y was hit". However, in special
cases (switching console into raw mode), you'll get all information (if
available...), as for example X11 indeed does use any information
available.
MfG, JBG
--
Jan-Benedict Glaw jbglaw@lug-owl.de . +49-172-7608481
"Eine Freie Meinung in einem Freien Kopf | Gegen Zensur
fuer einen Freien Staat voll Freier Bürger" | im Internet!
Shell Script APT-Proxy: http://lug-owl.de/~jbglaw/software/ap2/
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
next prev parent reply other threads:[~2003-01-07 7:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-01-06 14:29 Curses and key-up information Steve Goodwin
2003-01-06 16:00 ` Glynn Clements
2003-01-07 7:08 ` Jan-Benedict Glaw [this message]
-- strict thread matches above, loose matches on Subject: below --
2003-01-07 11:49 Steve Goodwin
2003-01-17 0:17 ` +RudyMartin
2003-01-17 11:21 ` Jan-Benedict Glaw
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030107070810.GD2529@lug-owl.de \
--to=jbglaw@lug-owl.de \
--cc=linux-c-programming@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).