From owner-freebsd-questions@FreeBSD.ORG Mon Oct 21 23:28:19 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 34AFCAD3 for ; Mon, 21 Oct 2013 23:28:19 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mx01.qsc.de (mx01.qsc.de [213.148.129.14]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id EDE1F2EAB for ; Mon, 21 Oct 2013 23:28:18 +0000 (UTC) Received: from r56.edvax.de (port-92-195-117-74.dynamic.qsc.de [92.195.117.74]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx01.qsc.de (Postfix) with ESMTPS id 87CCD3C752; Tue, 22 Oct 2013 01:28:10 +0200 (CEST) Received: from r56.edvax.de (localhost [127.0.0.1]) by r56.edvax.de (8.14.5/8.14.5) with SMTP id r9LNS44T003154; Tue, 22 Oct 2013 01:28:04 +0200 (CEST) (envelope-from freebsd@edvax.de) Date: Tue, 22 Oct 2013 01:28:04 +0200 From: Polytropon To: Gary Kline 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> Organization: EDVAX X-Mailer: Sylpheed 3.1.1 (GTK+ 2.24.5; i386-portbld-freebsd8.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: FreeBSD Mailing List X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: Polytropon List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Oct 2013 23:28:19 -0000 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, ...