From owner-freebsd-questions@FreeBSD.ORG Mon Oct 21 23:49:54 2013 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 6BF71361 for ; Mon, 21 Oct 2013 23:49:54 +0000 (UTC) (envelope-from kline@thought.org) Received: from p3plsmtpa08-01.prod.phx3.secureserver.net (p3plsmtpa08-01.prod.phx3.secureserver.net [173.201.193.102]) by mx1.freebsd.org (Postfix) with ESMTP id 4BAA72FC0 for ; Mon, 21 Oct 2013 23:49:53 +0000 (UTC) Received: from ethic.thought.org ([209.180.213.209]) by p3plsmtpa08-01.prod.phx3.secureserver.net with id fzpm1m00F4XeM0101zpmay; Mon, 21 Oct 2013 16:49:47 -0700 Date: Mon, 21 Oct 2013 16:49:26 +0000 From: Gary Kline To: Polytropon Subject: Re: howto recognize the Shift and Alt keys when /pressed\ Message-ID: <20131021164926.GA19974@ethic.thought.org> References: <20131021161200.GA18556@ethic.thought.org> <20131022012804.98a017fa.freebsd@edvax.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20131022012804.98a017fa.freebsd@edvax.de> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: FreeBSD Mailing List X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Oct 2013 23:49:54 -0000 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