Displaying unicode text works quite well in PsychoPY3, via using u before unicode data.
However event.getKeys cannot receive any non-ascii input in MacOS. (I believe the situation might same in Windows).
Also we can test what_key.py demo in coder.
when I press ‘a’ key twice, the output shows it properly.
['a']
['a']
However, when I change the input keyboard through cmd+space and press same key, it shows below error.
Traceback (most recent call last):
File "_ctypes/callbacks.c", line 234, in 'calling callback function'
File "/Applications/PsychoPy3.app/Contents/Resources/lib/python3.6/pyglet/libs/darwin/cocoapy/runtime.py", line 1121, in objc_method
result = f(py_self, *args)
File "/Applications/PsychoPy3.app/Contents/Resources/lib/python3.6/pyglet/window/cocoa/pyglet_view.py", line 158, in pygletKeyDown_
symbol = getSymbol(nsevent)
File "/Applications/PsychoPy3.app/Contents/Resources/lib/python3.6/pyglet/window/cocoa/pyglet_view.py", line 52, in getSymbol
return charmap[chars[0].upper()]
KeyError: '\u3141'
When use ‘input’ function in Python3.x commandline, it successfully store and print unicode keystrokes.
Is there any way to use input instead of PsychoPy key func. in PsychoPy?
OS (e.g. Win10): Mac OS 10.3.6 PsychoPy version (e.g. 1.84.x): 3 Standard Standalone? (y/n) If not then what?: y
The problem is not in PsychoPy or Python3. It seems the error happens in Pyglet level.
I tested several keyboard setting in MacOS High Sierra.
(English, Germany, Japanese, and Chinese)
When non-latin input is inserted to PsychoPy with Pyglet backend, it presents KeyError.
When change to the PyGame backend, it simply ignore keyboard language and receive alphabet.
Tried modified version (to work with Python3) of below,
Yes, as you mentioned, there is no problem to present unicode text stimuli, or import unicode data from csv.
However, I am trying to get ‘text string (a.k.a. free text, not a single key)’ response of various non-latin languages and realized that none of existing codes works for it in PsychoPy3.
It supersedes the event module and provides much better timing. I’m not sure if it will handle the actual returned characters any differently, but at least it is more likely that we can get changes made to the source code if required.
I checked new Keyboard class as you told.
It provides similar error when the key input is changed.
I think, the code modification is needed ‘international (non-ascii)’ text string input.