Tag Archives: pyHook

The Great Soul-Searching Odyssey, Part I

March has come and gone, and the blog has lain dormant this whole time. Not cool, Ryan. Not cool. So what have I been up to in that time? It turns out quite a lot, though not as much of it was as productive as I would have liked. Here is my tale.

Remember back in February when I happily wrote about creating my first keyboard handler? (If not, just jump down to the next post. Go ahead. I’ll wait.) It turns out that, despite the awesomeness of said handler, JAWS, the eternal programming thorn in my side, didn’t want to play nice with my code. In particular, it wanted to steal the use of the arrow keys for itself, thus keeping them out of my program. As any of you who have had to put JAWS to sleep in order to play a large chunk of audio games can attest, this is pretty annoying.

I was determined to figure this problem out, however, so I started searching high and low for solutions. The title didn’t lie. This really is an odyssey.

First, I traveled to the land of the great and powerful Pygame developers. Well actually, I just wrote an email to their listserv. Be that as it may, many of them recommended a module called pyHook, a powerful artifact which, according to legend, could freeze the dreaded JAWS in its tracks and prevent it from making off with my arrow keys. But oh man. PyHook is something like 10 points beyond my current skill level, and even its documentation was nearly indecipherable to my n00b mind.

Nevertheless, I threw everything I had against pyHook, aided somewhat by a wise old sage named Alec the Brave.* After what seemed like 10 days—because that’s about how long it was—I managed to throw together a workable solution that allowed me to run my demo side scroller and keep JAWS up and running at the same time. Some of you probably saw my exuberant tweet on the subject.

*Alec’s wisdom is beyond reproach, though his age and sage status have yet to be determined.

Alas, though, my struggles were for naught, for as soon as I began to tweak and debug the program, I realized that pyHook—and here I’ll use the technical phrase—“broke the hell out of” my keyboard module. I’ll spare everyone the gritty details, but suffice it to say that holding down keys was a nightmare, and even though the arrow keys kind of worked, they absolutely didn’t work if something like the control key was held down. All of this meant that if I chose to continue to use pyHook, I would invalidate the eight days I had spent designing and implementing my keyboard handler. What’s more, I had once again run out of ideas on how to proceed.

So what did I learn from the first leg of my journey? I learned that sometimes, the problem I need to solve isn’t as immediate as I think. More than that, I learned that it’s way too easy to get bogged down in side projects that leave me no time for working on important things—like punching a clown in the face. When the day comes that JAWS speech is a deal breaker, I’ll figure out the arrow key problem. Either that, or I’ll have it done for me by someone with a lot more expertise and skill.

Until then, I want to code a game, and that’s just what I intend to do.

Therein, however, lies the next step on my soul search, but since it’s almost midnight, I’ll have to save it for another day.