Date: Tue, 22 Oct 2013 12:59:01 +0200 From: Polytropon <freebsd@edvax.de> To: Gary Kline <kline@thought.org> Cc: FreeBSD Mailing List <freebsd-questions@freebsd.org> Subject: Re: howto recognize the Shift and Alt keys when /pressed\ Message-ID: <20131022125901.6f3366fd.freebsd@edvax.de> In-Reply-To: <20131021164926.GA19974@ethic.thought.org> References: <20131021161200.GA18556@ethic.thought.org> <20131022012804.98a017fa.freebsd@edvax.de> <20131021164926.GA19974@ethic.thought.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 21 Oct 2013 16:49:26 +0000, Gary Kline wrote: > since im using curses/ncurses, I just use getch(0. I.e., > > c = getch(); > > which works fine for everything except the modifier keys like ahift > and alt and ctl. if there is another way within X11, let's hear > it! In this case I have to remain silent. As far as I know, there is no way to capture modifier keys with this means as _individual_ key presses. In case you really want to implement that functionality, you'll have to "go down a few levels" and hook directly into the keyboard driver which, unlike the ncurses library that is tied to the console driver, is able to recognize modifier keys as individual keys. In "upper levels", this information is fully lost (press and release Shift key) or combined with other information (press Shift key, press letter 'k', release both, a capital 'K' will be written to the keyboard buffer that terminal-based applications can then read). The only way I'd see would be to assign a totally different keysym to the modifier keys, but that again would prevent them from working as they are intended. Here's an example for a ~/.modmaprc that would map the modifier keys to additional PF keys (PF25 to PF33). ! left control keycode 37 = F25 ! left meta keycode 115 = F26 ! left alt keycode 67 = F27 ! left shift keycode 50 = F28 ! caps lock keycode 66 = F29 ! right shift keycode 64 = F30 ! right alt, alt gr keycode 113 = F31 ! right meta keycode 116 = F32 ! compose keycode 117 = F33 Note that I've generated this example from a Sun USB Type 7 keyboard with has Meta keys, a Compose key, but no right Control key, so I can't check that. The keycodes can be easily obtained with "xev". Also consider Num Lock: It's not a modifier key, but does not emit anything into the keyboard buffer. It's key code in X is 77. :-) -- 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?20131022125901.6f3366fd.freebsd>