Numerical keyboard Python
<p>I am recording responses during a simple calculation task in Python, and I am storing these in a string. I would like to use the numerical part of the keyboard, but these give for instance 'num_1' instead of '1'. It probably has something to do that I store the input as a Text Stimulus in PsychoPy.. Any way to get around this? </p>

<pre><code>CapturedResponseString = visual.TextStim(myWin, 
                        units='norm',height = 0.2,
                        pos=(0,-0.40), text='',
                        alignHoriz = 'center',alignVert='center', color=[-1,-1,-1])

captured_string = '' #key presses will be captured in this string
</code></pre>

<p>If all your responses are preceded by "num_" you can just amputate them. For example <code>int(CapturedResponseString[4:])</code> will grab the numerical portion and turn it into an integer. </p>

<p>Python has lots of string processing tools that are much more sophisticated than this, and they are all available to you when using Psychopy. For example you could also split at the underscore. <code>CapturedResponseString.split('_')</code> will return a list with the stuff before the underscore in the first position and the rest in the second (assuming only one underscore).</p>

python psychopy