event.getkeys() key list

4,995 views
Skip to first unread message

Alex Holcombe

unread,
Mar 2, 2010, 9:29:14 PM3/2/10
to psychopy-users
Hi,
where can I find a list of the key names possible to be returned by
event.getKeys() ?
Might be nice to provide a link to such a list in the relevant part of
the documentation (http://www.psychopy.org/api/event.html )
By experimentation I discovered that the escape key is 'escape', left
arrow is 'left', down arrow is 'down', etc. which is all very nice.
But would be good to have the full list.

By the way Jon, the new IDE editor features showing the whitespaces
and distinguishing between space and tab and showing indentation is
very nice! Helps remedy some minor annoyances of python

Jon Peirce

unread,
Mar 3, 2010, 7:02:55 AM3/3/10
to psychop...@googlegroups.com


Alex Holcombe wrote:
Hi,
where can I find a list of the key names possible to be returned by
event.getKeys()  ?
Might be nice to provide a link to such a list in the relevant part of
the documentation (http://www.psychopy.org/api/event.html )
By experimentation I discovered that the escape key is 'escape', left
arrow is 'left', down arrow is 'down', etc. which is all very nice.
But would be good to have the full list.

  
At the moment what psychopy returns depends on the backend being used. For pyglet it returns the output of
    pyglet.window.key.symbol_string(keyNumber)
converted to a lower-case string. The full list of possible outputs for that are at the bottom of this mail
For pygame it returns the output of
    pygame.key.name(keycode)
I guess we should make them output identical values, but i've never had the need.

Out of interest, how do you feel about number pad keys? Should they be treated as identical to the number equivs (so that pressing 1 on the numberpad is equivalent to pressing on the top row) or should the difference be maintained between them (more confusin for beginners, but more key options for experts)?


By the way Jon, the new IDE editor features showing the whitespaces
and distinguishing between space and tab and showing indentation is
very nice!  Helps remedy some minor annoyances of python

  
glad you like it. A postdoc in our group was complaining about indentation errors. Note that the behaviour can be controlled with shortcut keys (that you can see in the view menu).

Jon


pyglet key list:
1
2
3
4
5
6
8
16
space
exclamation
doublequote
pound
dollar
percent
ampersand
apostrophe
parenleft
parenright
asterisk
plus
comma
minus
period
slash
_0
_1
_2
_3
_4
_5
_6
_7
_8
_9
colon
semicolon
less
equal
greater
question
at
bracketleft
backslash
bracketright
asciicircum
underscore
quoteleft
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
braceleft
bar
braceright
asciitilde
128
256
backspace
tab
linefeed
clear
return
pause
scrolllock
sysreq
escape
home
left
up
right
down
pageup
pagedown
end
begin
select
print
execute
insert
undo
redo
menu
find
cancel
help
break
modeswitch
numlock
space
tab
enter
f1
f2
f3
f4
home
left
up
right
down
prior
next
end
begin
insert
delete
multiply
add
separator
subtract
decimal
divide
0
1
2
3
4
5
6
7
8
9
equal
f1
f2
f3
f4
f5
f6
f7
f8
f9
f10
f11
f12
f13
f14
f15
f16
loption
roption
lshift
rshift
lctrl
rctrl
capslock
lmeta
rmeta
lalt
ralt
lwindows
rwindows
lcommand
rcommand
delete

This message has been checked for viruses but the contents of an attachment may still contain software viruses which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation.

Alex Holcombe

unread,
Mar 3, 2010, 5:16:15 PM3/3/10
to psychopy-users
Hi Jon
thanks for the keys. I would suggest hyperlinking to or mentioning the
corresponding pygame and pyglet key functions in the help document. I
don't have an opinion about the numeric keypad- it will confuse
newbies if they are different, but will annoy some experts if they are
the same. You can't win. Although adding notes about this to the
documentation helps of course.

I also want to ask about a new behavior I'm seeing in the output
window. I am issuing a series of print statements that dump debugging
info to the output window (see below for a snippet). To my amazement,
in the below when it appears in the output window everything from
"trialnum = 1" to "16.3" is displayed in red. I have no idea why this
is happening, especially since the following numbers are part of the
same print statement. Perhaps the 16.3 is the end of the first line,
and the output window in its wisdom (triggered by the "ERROR" text?)
printed just that line in red.
---------------------------------------------------------
[1 5]] or 0 test 0.3 -1.0 -1 0 0 0 4 3 2 1 5 3 4 21
trialnum= 1 ERROR,21 frames were longer than 25.0 msnot printing
them all because in demo mode flankers also=[ 18.4 39.6 5.9 20.
32.4 18.6 10.5 30. 26.3 30. 26.3 16.3
24.2 26. 20.1 9.4 31. 25.1 31. 25.1 17.4 22.9 35.
14.2
17.3 48.4 9.7 16.4 26. 25.1 26. 25.1 25.6 25.1 25.6
24.
24. 25.3 8.1 8.3 49.7 11. 20.2 41.7 8.3 16.1 28.4
7.3
22.5 26.4 15.7 15.7 30.7 28.9 30.7 28.9 15. 11.6 38.4
8.1
8.1 48.2 19.6]

On Mar 3, 11:02 pm, Jon Peirce <jonathan.pei...@nottingham.ac.uk>
wrote:
> Alex Holcombe wrote:Hi, where can I find a list of the key names possible to be returned by event.getKeys() ? Might be nice to provide a link to such a list in the relevant part of the documentation (http://www.psychopy.org/api/event.html) By experimentation I discovered that the escape key is 'escape', left arrow is 'left', down arrow is 'down', etc. which is all very nice. But would be good to have the full list.At the moment what psychopy returns depends on the backend being used. For pyglet it returns the output of


>     pyglet.window.key.symbol_string(keyNumber)
> converted to a lower-case string. The full list of possible outputs for that are at the bottom of this mail
> For pygame it returns the output of
>     pygame.key.name(keycode)
> I guess we should make them output identical values, but i've never had the need.

> Out of interest, how do you feel about number pad keys? Should they be treated as identical to the number equivs (so that pressing 1 on the numberpad is equivalent to pressing on the top row) or should the difference be maintained between them (more confusin for beginners, but more key options for experts)?By the way Jon, the new IDE editor features showing the whitespaces and distinguishing between space and tab and showing indentation is very nice! Helps remedy some minor annoyances of pythonglad you like it. A postdoc in our group was complaining about indentation errors. Note that the behaviour can be controlled with shortcut keys (that you can see in the view menu).

Jon Peirce

unread,
Mar 4, 2010, 3:48:59 AM3/4/10
to psychop...@googlegroups.com

Alex Holcombe wrote:
> Hi Jon
> thanks for the keys. I would suggest hyperlinking to or mentioning the
> corresponding pygame and pyglet key functions in the help document. I
> don't have an opinion about the numeric keypad- it will confuse
> newbies if they are different, but will annoy some experts if they are
> the same. You can't win. Although adding notes about this to the
> documentation helps of course.
>
>

I know; we'll have them be equivalent by default and provide a
preference to override that.


> I also want to ask about a new behavior I'm seeing in the output
> window. I am issuing a series of print statements that dump debugging
> info to the output window (see below for a snippet). To my amazement,
> in the below when it appears in the output window everything from
> "trialnum = 1" to "16.3" is displayed in red. I have no idea why this
> is happening, especially since the following numbers are part of the
> same print statement. Perhaps the 16.3 is the end of the first line,
> and the output window in its wisdom (triggered by the "ERROR" text?)
> printed just that line in red.
>

haha, yes. Any line that includes the word error now gets coloured red,
and any warning gets coloured green. I thought this would help people
spot the critical lines in output when experiments go wrong. But maybe
we need to do something more fancy than just looking for 'ERROR' for
this reason.

Jon

Alex Holcombe

unread,
Mar 4, 2010, 6:44:16 PM3/4/10
to psychopy-users

I like it, it certainly does help highlight errors. Nifty! That's ok
with me if it's just doing a dumb search, it's still helpful. Is it in
the documentation somewhere?

Reply all
Reply to author
Forward
0 new messages