Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 Oct 2013 16:49:26 +0000
From:      Gary Kline <kline@thought.org>
To:        Polytropon <freebsd@edvax.de>
Cc:        FreeBSD Mailing List <freebsd-questions@freebsd.org>
Subject:   Re: howto recognize the Shift and Alt keys when /pressed\
Message-ID:  <20131021164926.GA19974@ethic.thought.org>
In-Reply-To: <20131022012804.98a017fa.freebsd@edvax.de>
References:  <20131021161200.GA18556@ethic.thought.org> <20131022012804.98a017fa.freebsd@edvax.de>

next in thread | previous in thread | raw e-mail | index | archive | help
Organization: Thought Unlimited.  Public service Unix since 1986.
Of_Interest: With 27 years  of service  to the  Unix  community.

On Tue, Oct 22, 2013 at 01:28:04AM +0200, Polytropon wrote:
> 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?


	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!


> 
> -- 
> Polytropon
> Magdeburg, Germany
> Happy FreeBSD user since 4.0
> Andra moi ennepe, Mousa, ...

-- 
 Gary Kline  kline@thought.org  http://www.thought.org  Public Service Unix
             Twenty-seven years of service to the Unix community.
                            http://www.thought.org/HOPE





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