0

I've got such problem - when I pressing keyboard button in russian layout my application crushes with such message

UnicodeEncodeError: 'ascii' codec can't encode character '\u0444' in position 40: ordinal not in range(128)

code:

 event = pygame.event.poll()
 if event.type == KEYDOWN:
    print(event)

(I've pressed latin 'a') Pressing keys on English layout - works fine.

By the way - when I'm changing event.type == KEYDOWN to event.type == KEYUP - everything works, but in thi case I cannot access event.unicode param to get pressed key

Can some one advise me how to make it working with any keyboard layout KeyDown events?

Thanks!

Vlad S.
  • 51
  • 8

1 Answers1

0

Try to add this line in the beginning of your file:

# -*- coding: utf-8 -*-
sissi_luaty
  • 2,839
  • 21
  • 28
  • this is already added in each file and just tells to language interpreter in what encoding it should open file – Vlad S. Mar 01 '13 at 11:30