event.getKeys() doesn't recognize the keyboard input

732 views
Skip to first unread message

Mauricio Aspé Sánchez

unread,
Nov 4, 2012, 11:32:29 AM11/4/12
to psychop...@googlegroups.com
Dear all:
I've got a problem with event.getKeys(). It doesn't recognize the keyboard input. For instance, this little test code above give me just '[]' as output, both for the 'q' key as for any key I press (it would recognize just 'q' as input). 

In addition, I get the error
Inconsistency detected by ld.so: dl-close.c: 759: _dl_close: Assertion `map->l_init_called' failed!

I'm currently using the coder in Psychopy v1.74.03 under Linux Mint Maya.

Somebody could help me?

All the best and thanks a lot!
Mauricio.

from psychopy import visual, core, event

mainWindows = visual.Window(size = (300, 200), monitor = 'testMonitor')  

for frame in range(300):
    mainWindows.flip()
    
    if len(event.getKeys()) > 0:
        k = event.getKeys(['q'])
        print k
        
mainWindows.close()
core.quit()



Jonathan Peirce

unread,
Nov 4, 2012, 11:41:40 AM11/4/12
to psychop...@googlegroups.com
It does recognise the keyboard, but when you call that function it
discards the key presses so that they don't show up next time.

So your getKeys(['q']) call is made immediately after the key presses
have been cleared and so the list is empty. Make sense?

What you want is this:

from psychopy import visual, core, event
mainWindows = visual.Window(size = (300, 200), monitor = 'testMonitor')
for frame in range(300):
mainWindows.flip()
#check keys
keys = event.getKeys()#store for multiple uses
if len(keys):
print keys
if 'q' in keys:
core.quit()
mainWindows.close()
core.quit()

Jon
> --
> You received this message because you are subscribed to the Google
> Groups "psychopy-users" group.
> To post to this group, send email to psychop...@googlegroups.com.
> To unsubscribe from this group, send email to
> psychopy-user...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/psychopy-users/-/NWXHRU8HqAIJ.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

--
Jonathan Peirce
Nottingham Visual Neuroscience

http://www.peirce.org.uk/

Jonathan Peirce

unread,
Nov 4, 2012, 11:48:58 AM11/4/12
to psychop...@googlegroups.com

On 04/11/2012 16:32, Mauricio Asp� S�nchez wrote:
>
> In addition, I get the error
> Inconsistency detected by ld.so: dl-close.c: 759: _dl_close: Assertion
> `map->l_init_called' failed!
This one has been reported on the list numerous times (you could google it)
Nobody seems know what causes it - it seems to be to do with
opengl+linux (+nvidia?) but doesn't actually cause any actual problems
as far as we can tell.

Jon

Mauricio Aspé Sánchez

unread,
Nov 4, 2012, 12:11:04 PM11/4/12
to psychop...@googlegroups.com
Hi Jon!
It works perfect, thanks a lot!

Mauricio.


2012/11/4 Jonathan Peirce <jon.p...@gmail.com>
--
You received this message because you are subscribed to the Google Groups "psychopy-users" group.
To post to this group, send email to psychopy-users@googlegroups.com.
To unsubscribe from this group, send email to psychopy-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.





--
Mauricio A. Aspé Sánchez


"el lujo es vulgaridad"

Reply all
Reply to author
Forward
0 new messages