[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] pyHooking the Arrow Keys
- To: <pygame-users@xxxxxxxx>
- Subject: [pygame] pyHooking the Arrow Keys
- From: "Ryan Strunk" <ryan.strunk@xxxxxxxxx>
- Date: Mon, 19 Mar 2012 20:32:50 -0500
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Mon, 19 Mar 2012 21:32:55 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:mime-version:content-type :content-transfer-encoding:x-mailer:thread-index:content-language; bh=mbTT/BLqMArTUTApWpRgm2K+7nKyBmYy9aidOBTcub4=; b=0JOPG2USypTyoIjSx6ZiCQKMThYSeiSVt/JCgrDfYsgzM6KjvL7xaetPhCmukNILf2 tGuYVD7kpB9MFxhALMcKJz1kmw1m8eGtCsO67GSOt/iH5x2wSrSaDXBsI5TkCujUQiTf W0IMbhhhPo4nLTzmsKVS50U2awDaq5+q7RkKtAiE7JBpwRLjH6f1hpzHzv1+HFCo8bF3 7hs5PGDd4HESHBBA2KW9I+GtEYU3zE25VOmvjm5gOtObTrzOtB74HTOVeaAQw9ZYMxVo twrJAp5NdEiHGSgeT8ogLmnKQ/QJav71xKhSnkbrBwPteKKj5+4qU22WuaINfRa/u5y2 SvdA==
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
- Thread-index: Ac0GOVR/3/U17F6bQ46M60ovu/8xZA==
Hi everyone,
I wrote a little while back about how I wanted to tie the arrow keys
specifically to my program so that they could be used exclusively for the
program instead of being intercepted by a screen reader. I attempted to
modify the code from the tutorial I found, but it is producing some rather
strange results. In addition to not allowing the arrow keys to work inside
of the program, the program also blocks the arrow keys in other windows. Can
anyone tell me, please, what is going wrong and how I can fix it?
Here is the code I have pasted at the bottom of my main file:
def OnKeyboardEvent(event):
# return True to pass the event to other handlers
return (event.Key not in ['Up', 'Down', 'Right', 'Left'])
# create a hook manager
hm = pyHook.HookManager()
hm.KeyDown = OnKeyboardEvent
hm.HookKeyboard()
pythoncom.PumpMessages()
Thanks for your help.
Best,
Ryan