Tuesday, March 23, 2010

Figuring it out

Well, my tutor and I didn't get any code written today; the lesson was taken up with trying to make SendKeys work, with next to no success. The problem is that SendKeys was written for Python 2.1 and was last updated in 2003. We've been writing Plover in Python 3.1, so it doesn't work. Our options are:

* Figuring out a way of updating SendKeys so it's compatible with Python 3.
* Revising Plover so that it's compatible with SendKeys as it is (might be tricky because pyserial requires Python 2.3 or later; plus my heart bucks against the idea of regressing backwards into the unsupported Pythonic past.)
* Finding an alternative to SendKeys -- possibly using the script found in the last comment of this?

On the hardware side of things, I just ordered a Sidewinder X4, which I mentioned in an earlier post. If it's really true that multiple keys of the keyboard will be recognized as chords, maybe I can train my fingers to ignore the slight misalignment between rows and learn how to play the qwerty keyboard like a steno machine. That is:


would map to


I tried a little bit experimentally on my laptop's keyboard, just mashing keys into a Vim window ("just mashing keys into a Vim window" came out as "mapfdsxkejrlscn;wxoianfmpdimn", but I think some of the letters weren't recognized, since my Lenovo's keyboard doesn't have any anti-ghosting abilities), and it feels weird, but I think it might be possible with practice. The main barrier I'm worried about is that of determining spaces between strokes. Steno machines register keypresses once all of the keys have been lifted; qwerty keyboards register keypresses as soon as each one is pushed down. Will it be possible to put in some sort of software hack that registers each stroke as finished every time the keyboard realizes that none of its keys are being pressed?


Unknown said...

Hm. I don't know if anything I know is relevant - all I know is web applications - but I do know that most implementations of JavaScript see three different events (with variation between browsers): onkeydown fires when the key is first pushed down, onkeyup fires when the key is first released, and onkeypress fires whenever the key is recognized as having been pressed. (That last is kind of complicated to explain. When you push "a", onkeydown and onkeypress both fire. If you hold it down so that you're going "aaaaaaaa", onkeypress fires again each time an "a" gets sent. When you release "a", onkeyup fires.)

I don't know if there's anything useful there for you, but I believe that, on some level, the computer recognizes those as separate events. Whether Python gives you the tools to tell which event it was, I don't know.

Mirabai Knight said...

That's really good to know! Thank you. So I have to get the keyboard to tell me when onekeyup has been fired for every key that's had a recent onekeydown event. When all the onekeyups have been registered, we send the stroke. Right? I guess I'm going to have to set letter repeating to as long as I can make it, though, so we don't have an aaaaaaaa situation.