Date: Fri, 7 Oct 2011 09:56:20 +0200 From: Polytropon <freebsd@edvax.de> To: Robert Bonomi <bonomi@mail.r-bonomi.com> Cc: freebsd-questions@freebsd.org Subject: Re: OT: how to tell when i've hit a Fn key? Message-ID: <20111007095620.8b78e334.freebsd@edvax.de> In-Reply-To: <201110070736.p977anOs027817@mail.r-bonomi.com> References: <20111007091857.33b47b19.freebsd@edvax.de> <201110070736.p977anOs027817@mail.r-bonomi.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 7 Oct 2011 02:36:49 -0500 (CDT), Robert Bonomi wrote: > > > Date: Fri, 7 Oct 2011 09:18:57 +0200 > > From: Polytropon <freebsd@edvax.de> > > Cc: FreeBSD Mailing List <freebsd-questions@freebsd.org> > > Subject: Re: OT: how to tell when i've hit a Fn key? > > > > On Thu, 6 Oct 2011 15:41:17 -0700, Gary Kline wrote: > > > > > > I've got a 103-key keyboard. most of them produce the right WAV > > > file. i was having some trouble with the arrow key, but think i've > > > found a resolution. next are the Function key, F1 to F12. > > > > > > anybody on-list familiar with curses and can help me with this? > > > right now, most of the function keys output 4 clicks [!]. > > > > Capturing PF keys is very easy with ncurses. > > The macro KEY_F(n), n=1..12, can be checked > > as the result of the getch() function. The > > other "special keys" also have such macros > > assigned. You can find them in the header > > file /usr/local/include/ncurses/ncurses.h > > around line 1400. > > No need to go chasing that far. > > #include <ncurses.h> > > pulls in the macro definitions as well. That's what I wanted to suggest. :-) The NCurses function getch() deals well with the key macros defined here, so no need to deal with the zero-byte manually. > KEY_F(n) supports 'n' values in the range from 0 to 64. > value of this macro is a range of 64 consecutive values, starting with > KEY_F0 -- which is defined as *octal* 0410 > > it may take a little experimenting to see which key (plus modifier key(s) > like 'shift','control', etc, map to which 'n' values) The port misc/kbdscan can be used to obtain keyboard information; however: "Please note that this program will only work in the FreeBSD console", but it works perfectly in the FreeBSD console (text mode); after a certain time-out, the program automatically quits as it will capture _all_ keys like Alt+F(n), ^C and the like. Sadly, there is no manpage that states this simple fact. :-( In most cases, KEY_F(1) - KEY_F(12) will map to the physical F1 to F12 keys, KEY_F(13) - KEY_F(24) to the Shift+F1 to Shift+F12 keys; this mechanism has been the default idea of providing 24 function keys to keyboards that only offer 12 of them. But as many things that have proven to work flawlessly, this might have changed into something broken, erm "more modern"... -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20111007095620.8b78e334.freebsd>