[ale] Slightly OT: Coding program to hit several keys at once

Horkan Smith ale at horkan.net
Tue Dec 5 17:03:53 EST 2017


There are several ways to see keyboard input, w/ a variety of limitations - does it work over ssh, does it handle 'special' keys, does it send independent events for press vs release, etc.

For console, take a look at the 'showkey' program, which (at least in Debian/Ubuntu) part of the 'kbd' package.  If you use the keycodes mode (default), it will show you press and release for almost any key on your keyboard.  If that seems like it's working for you, just grab the source via 'apt-get source kbd'

For X windows, take a look at the 'xev' program - it reports any X-windows events, including press and release.  There may be (hopefully will be?) a wrapper (Qt, Gtk, etc.) for those events - I haven't done it, but my understanding is the raw X11 stuff is, well, *raw*. 8-/

You might also want to look at the pygame and TkInter packages - I google'd for 'python key release event' and got links that pointed that'away.  (Looks like you may already know about pygame.)

There are almost certainly others - I think there's a way to use /dev/hidraw*, but I'm not sure it'll give you release events.

later!
   horkan

On Tue, Dec 05, 2017 at 10:22:28AM -0600, Todor Fassl via Ale wrote:
>I want to write some code to simulate a braille keyboard. A braille 
>keyboard has 7 keys. One is the space bar. The other 6 you press at 
>the same time in different combinations. So, for example, on a braille 
>keyboard, to make the letter x, you press the 1, 3, 4, and 6 keys at 
>once. I want to simulate that by allowing the user to press the f, s, 
>j, and l keys at the same time. Does anybody know of a programming 
>language that handles something like that nicely? If you were going to 
>recommend a programming language to do that, what would it be?
>
>My goal is to write a text editor that allows a user to type braille 
>and saves the output in BRF format. So the user hits the f, s, j, and 
>l keys at once and the editor puts a BRF character x into the buffer.
>
>Right now, I'm leaning toward python because python has a gaming 
>library that seems to allow you to hit several keys at once. But maybe 
>somebody has done something like this in C or C++. I am about as sure 
>as I can be that perl won't work. I don't particularly care about the 
>programming language because by now I've learned so many different 
>programming languages in my life I figure I can learn another one in a 
>few days/weeks. I don't actually care if the code is portable to other 
>operating systems other than linux.  That might be nice but it's not 
>important.
>
>
>-- 
>Todd
>_______________________________________________
>Ale mailing list
>Ale at ale.org
>http://mail.ale.org/mailman/listinfo/ale
>See JOBS, ANNOUNCE and SCHOOLS lists at
>http://mail.ale.org/mailman/listinfo

-- 
Horkan Smith
678-777-3263 cell, ale at horkan.net


More information about the Ale mailing list