Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 22 Oct 2013 01:28:04 +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:  <20131022012804.98a017fa.freebsd@edvax.de>
In-Reply-To: <20131021161200.GA18556@ethic.thought.org>
References:  <20131021161200.GA18556@ethic.thought.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 21 Oct 2013 16:12:00 +0000, Gary Kline wrote:
> 	even ESC works; the arrow keys, everything.  I cant figure out gow
> 	to fet the left and right shift, alt, anf control keys.  
> 	xev fails me here: is says that the leftShift is 0xffe1 or in
> 	dec 65505.

I'm not sure because those are modifier keys (and Meta,
AltGr and maybe Compose would also be). They don't send
an individual key code that can be received in the usual
manner. Instead, they modify the value of another key
that can then be evaluated. The normal console driver doesn't
"hand them through" to the upper layers so the keycodes
can be "captured" by something like ncurses getch().
Similarly ncurses does not define individual "key symbols"
for them as it does for all the other keys.

Of course, within X they can be captured (check the
output of the X event monitor "xev" for example). But
that's a different mechanism, here for example different
names (keysymbols) are used, like Shift_L, Meta_R, or
something user-defined (attached to a keycode with,
for example, xmodmap).

KeyPress event, serial 30, synthetic NO, window 0x2600001,
    root 0x1ad, subw 0x0, time 18201220, (-558,72), root:(195,381),
    state 0x10, keycode 50 (keysym 0xffe1, Shift_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False
KeyRelease event, serial 30, synthetic NO, window 0x2600001,
    root 0x1ad, subw 0x0, time 18201333, (-558,72), root:(195,381),
    state 0x11, keycode 50 (keysym 0xffe1, Shift_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

The key with the keycode 50 has been assigned the symbol
number 0xffe1 which is the name Shift_L. Unlike getch(),
within X it's easier to obtain a KeyPress and KeyRelease
event, whereas ncurses just "reads from the keyboard buffer",
and a single press of the left Shift key doesn't put
anything into that buffer.

What method of "capturing keys" do you use?


-- 
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?20131022012804.98a017fa.freebsd>