I'm on Mac OS X 10.6, and I have Dvorak, US Extended, and Norwegian in my keyboard input selector menu, and US Extended is the one I use.
When I run Pygame programs with keyboard input, pygame seems to think I'm using dvorak regardless of what is actually selected.
This is the part of the code that takes the keyboard input:
# Check for events
for event in pygame.event.get():
if event.type == KEYDOWN:
# Change the keyboard variables
if event.key == K_LEFT or event.key == ord('a'):
moveRight = False
moveLeft = True
if event.key == K_RIGHT or event.key == ord('d'):
moveLeft = False
moveRight = True
if event.key == K_UP or event.key == ord('w'):
moveDown = False
moveUp = True
if event.key == K_DOWN or event.key == ord('s'):
moveUp = False
moveDown = True
if event.type == KEYUP:
if event.key == K_ESCAPE:
pygame.quit()
sys.exit()
if event.key == K_LEFT or event.key == ord('a'):
moveLeft = False
if event.key == K_RIGHT or event.key == ord('d'):
moveRight = False
if event.key == K_UP or event.key == ord('w'):
moveUp = False
if event.key == K_DOWN or event.key == ord('s'):
moveDown = False
if event.key == ord('x'):
player.top = random.randint(0, WINDOWHEIGHT - player.height)
player.left = random.randint(0, WINDOWWIDTH - player.width)
The arrow keys work as they should, but the WASD keys are spread over the keyboard in a way consistent with Dvorak. So, "A" is in the same place on both layouts, "W" is on QWERTY's comma key, and so on. If I change the code to look for the a
, e
, ,
and o
keys instead, things work as expected.
How can I make Pygame use the correct layout?