So this is an easy fix. typingDemo.psyexp (8.5 KB)
All we need to do is add those keynames to the list of keys that will be accepted, and additionally create a dictionary containing what we want to display if one of those keys is pressed. Check out the turkishKeyMap below, and the âextend()â call used below it (I also had to modify how âentryCharsâ was first created):
Begin routine
import string
# Get a list of all upper and lowercase
# letters.
entryChars = [x for x in string.ascii_letters]
print(entryChars)
# A dictionary of keynames sent to psychopy
# (found with keyNameFinder demo), with the character
# we want to display when pressed
turkishKeyMap = {
'apostrophe': u'i',
'bracketleft': u'Ä',
'bracketright':u'ĂŒ',
'semicolon': u'Ć',
'comma': u'ö',
'period': u'ç',
'i': u'ı',
}
# Get a list of the dictionary keys and add to the
# list of key presses that will be accepted
entryChars.extend(turkishKeyMap.keys())
Now when we are checking for keypresses, we first see if that keyname is in our dictionary. If it is, we add the value from the dictionary to the TextStim, instead of the name of the keypress:
Each Frame
#### See attached file for complete code
elif key in entryChars:
if key in turkishKeyMap:
key = turkishKeyMap[key]
typingStim.setText(typingStim.text + key)
This takes care of your worry about âıâ not showing up. Note that if we didnât use this dictionary lookup code and you typed a word like âiçinâ, it would appear as âiperiodinâ . Hopefully that now makes sense to you.
Lastly, I would be diligent and test all of those lab computers individually, since hardware is not as uniform for Windows computers. If the keynames are different, you can add an additional dialog before the experiment starts where you can select what computer youâre using, and then reset turkishKeyMap . Hereâs a version that does that, note that I moved the definition of turkishKeyMap to a different routine with a code component:
typingDemo-chooseKeyboard.psyexp (9.7 KB)