[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Intercepting the Keyboard
- To: pygame-users@xxxxxxxx
- Subject: Re: [pygame] Intercepting the Keyboard
- From: Silver <rockachu2@xxxxxxxxx>
- Date: Thu, 08 Mar 2012 20:12:00 -0800
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Thu, 08 Mar 2012 23:12:12 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:x-enigmail-version:content-type :content-transfer-encoding; bh=YbvX/qAF1IO0nsz82TyIe/WMRRiJj+j6VRYC9/izuOg=; b=SRQ1WJ9JLJg3S9FvbWNckFcJZnRBWbaLVXdtxyxbTkvZVX29ngMV8f35Ukn3aZYyev 9tcqyTWTSmcgp6NQa9cO3uXCVuHao9WSxxwYsu4O9AJhCSlnyYqcaxd/g9PDS3ULM9ax YyAa9arEOAYl8DVK+Rve/V+8tMpREl9Snwx2K5GYE8F3vOJ6j2T599qPUizfBPgMgmzu GiFk64T1cNNHmOWsq3QCsVozzKYjmkNM9c4kytvuUG6j7G1XBC+rVYW6vKKHUG8EiWYZ pZ7pMqRzPaHN2nHiKCUiwhp8ffY9PFMp+hfWX1VrzkJw60WXX6akng0kF+sPT+tVKj40 Vulw==
- In-reply-to: <01e401ccfce0$71229f30$5367dd90$@gmail.com>
- References: <01e401ccfce0$71229f30$5367dd90$@gmail.com>
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
- User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2
On 3/7/2012 8:03 PM, Ryan Strunk wrote:
> Hello everyone,
> In creating audio-based games, I'm trying to make my programs work with
> major screen readers. The problem is that the industry leader, JAWS, likes
> to intercept keystrokes sent to the system. This means that if you build
> arrow key use into a pygame program, JAWS gets to your arrow keys first and
> processes them before Pygame can. Unfortunately, cutting out the screen
> reader isn't an option, as it's used to read any game text that might be
> written to the screen.
> I'm curious if anyone has recommendations as to how I could have Pygame or
> Python get to keyboard events before the rest of the system. I have a friend
> who was able to make this happen using C#.net, but I can't even begin to ask
> how or if it's possible to do this using Python.
> Any help you all can provide would be greatly appreciated.
> All the best,
> Ryan
>
Try using the pyHook. It allows you to catch these events really easily.
It also allows you to shut off keypresses, including ctrl-esc.
from ctypes import windll
import pyHook as pyhook
hardman = pyhook.HookManager()
hardman.KeyDown = [your key handling function here]
hardman.HookKeyboard()