Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

logging simultaneous key presses

I have got a problem with simultaneous key presses on one of the same stimulus.
I know that python/OS works in sequence and not in parallel. Nevertheless, I assume that on ms (or even microseconds?) two keys are very rarely pressed at the same time by human subjects.

Here is a little experiment that requires two key presses after a stimulus.

    kb = keyboard(keylist = ['f','g','h','j','LSHIFT','RSHIFT','d','k'])
    A = canvas()
    A.text('A')
    B = canvas()
    B.text('B')

    seq=[1,2]
    print seq, len(seq), (len(seq)-1), seq[1]

    seq = [A,B]*5 

    for i in range(10): 
        t = seq[i].show()
        var.T_Stim = t
        if seq[i] == A:
            var.Stim = 'A'      
        elif seq[i] == B:
            var.Stim ='B'


        key, time = kb.get_key()
        var.Resp=key
        var.T_Resp=time
        log.write_vars()

        key, time = kb.get_key()
        var.Resp=key
        var.T_Resp=time
        log.write_vars()

When i run the experiment i noticed that for almost simultaneous presses (difference ca. < 16ms) only one key is counted. I have to press a third time. The third is logged, together with one of the first.

An idea that came to my mind is that it might have to do with "keydown/keylift", because the first key is not lifted before the second key is pressed. I played around with this, and that is not the problem.

I am not sure whether there is a debounce interval in open sesame (in presentation you can manually set the debounce intervall, although this counts for presses of the same key only). Or does the get_key() command need so much time for processing?

Any ideas how to solve this?

Comments

  • Just tried it out, also happened for me sometimes when pressing the keys exactly at the same moment.

    I rewrote the code a bit (see below), cleaning the indents, using two different keyboard objects and flushing them after data collection (just to be save). I had the impression that performance improved a bit although in some cases the error still occurred.

    Besides, my impression was that the error was more likely to happen if one of the shift keys was involved, so it might make sense to use different keys for that. In this regard, it is also important to keep in mind that if shift is simultaneously pressed while e.g. pressing g, g will be logged as "G" in this case (which might - when ignored - lead to problems when processing the response later on).

    Final remark: depending on the specific instructions for the subjects and the experimental procedure it might be more or less likely that this exact simulateneous keypresses occur or not.

    Best,

    Pascal

    kb1 = keyboard(keylist = ['f','g','h','j','LSHIFT','RSHIFT','d','k'])
    kb2 = keyboard(keylist = ['f','g','h','j','LSHIFT','RSHIFT','d','k'])
    A = canvas()
    A.text('A')
    B = canvas()
    B.text('B')
    
    seq=[1,2]
    print seq, len(seq), (len(seq)-1), seq[1]
    
    seq = [A,B]*5 
    
    for i in range(10):
        t = seq[i].show()
        var.T_Stim = t
        if seq[i] == A:
            var.Stim = 'A'      
        elif seq[i] == B:
            var.Stim ='B'
    
        key1, time1 = kb1.get_key()
        key2, time2 = kb2.get_key()
    
        kb1.flush()
        kb2.flush()
    
        var.Resp1=key1
        var.T_Resp1=time1
        var.Resp2=key2
        var.T_Resp2=time2
    
        print i
        print var.Resp1, var.Resp2
        log.write_vars()
    
  • I haven't tried it out myself, but would it help if you used a timeout in your keyboard of 0 or maybe 1ms?

    Eduard

    Buy Me A Coffee

  • edited November 2016

    @Pascal
    Thanks Pascal for your remark of the upper-case letters. I did not notice that yet. At least we know now that the presses are recognized in some way. Although not logged.
    I have now changed it to LCTRL and RCTRL. (they shall press it with the left/right thumb on a laptop)

    On your final remark: I actually want participants to press the keys as simultaneous as possible.
    Hence the problem still exists. I need those second keypresses.

    @eduard
    i did not really understand how to implement timeout in my keyboard.
    When i do it like this ...
    key1, time1 = kb1.get_key(timeout=1)
    ...it only continues without any keypress. That is not what i want.

  • Oh sorry, that was incomplete. You would have to wrap a loop around the procedure, like this:

    while True:
         key1, time1 = kb1.get_key(timeout = 5)
         if key1 != None:
             break
    

    Eduard

    Buy Me A Coffee

  • edited November 2016

    @eduard YOU SAVED MY DAY!
    Great this works when i set it to 0 (and if i do not use shift or ctrl).

    kb1 = keyboard(keylist = ['f','g','h','j','<','-','d','k'])
    kb2 = keyboard(keylist = ['f','g','h','j','<','-','d','k'])
    A = canvas()
    A.text('A')
    B = canvas()
    B.text('B')

    seq = [A,B]*5

    for i in range(10):
    t = seq[i].show()
    var.T_Stim = t
    if seq[i] == A:
    var.Stim = 'A'
    elif seq[i] == B:
    var.Stim ='B'

    while True:
         key1, time1 = kb1.get_key(timeout = 0)
         if key1 != None:
             break
    while True:
         key2, time2 = kb2.get_key(timeout = 0)
         if key2 != None:
             break
    
    kb1.flush()
    kb2.flush()
    
    var.Resp1=key1
    var.T_Resp1=time1
    var.Resp2=key2
    var.T_Resp2=time2
    
    print i
    print var.Resp1, var.Resp2
    log.write_vars()
    

    Now i just need to change it, so that it continues always after the thumb button.
    Does OpenSesame collect key responses within the first (16) ms after a new visual stimulus is drawn?

  • The above mentioned script works fine on my computer at home (Win10). But in my office (Win7, uni network) from simultaneous key presses only one is registered.

    Any ideas why this is the case?

  • Nope, I don't know. Are you using the same Opensesame version?

    Buy Me A Coffee

  • It was the keyboard connection. USB is too slow or sends the information something different. The old purple keyboard connection works fine.

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games