Howdy, Stranger!

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

Supported by

[open] Collecting responses during a text display

edited October 2012 in OpenSesame

Hi,
Thanks in advance for any help.
I want to collect keypress responses during a text display screen. I cannot have the text display be set to a keypress time though because I'm doing a scanning experiment and need it to last a certain number of seconds. I see the keypress logger option, but I'm wondering if there's something I have to do to imbed it into the text display option?

Hope this makes sense! This is all quite new to me!
Thanks!
Sarah

Comments

  • edited October 2012

    Hi Sarah!

    You're very close! You can set your text_display item's duration to 0. After this, put in an inline_script to which - in the run phase - you add the following:

    from openexp.keyboard import keyboard
    
    # timeout in milliseconds
    maxtime = 3000
    
    # list of allowed keys
    allowedkeys = ['return', 'space', 'k', ';', '9', 'right']
    
    # create keyboard object
    my_keyboard = keyboard(self.experiment, keylist=allowedkeys, timeout=0)
    
    # wait for keyboard response or timeout
    no_timeout = True
    no_response = True
    starttime = self.experiment.time()
    while no_timeout:
        if no_response:
            pressed, presstime = my_keyboard.get_key()
            if pressed:
                self.experiment.set("response", my_keyboard.to_chr(pressed))
                self.experiment.set("response_time", presstime - starttime)
                no_response = False
        if self.experiment.time() - starttime >= maxtime:
            if no_response:
                self.experiment.set("response", 'timeout')
                self.experiment.set("response_time", None)
            no_timeout = False
    

    The allowed keys are now set fairly random (the return, 'k', ';' and '9' buttons, as well as the space bar and the right arrow button), but you can edit that any way you want.

    Hope this helps! (if not, please just give us a holler)

    N.B.: this inline_script will replace the function of a keyboard_response, so you do not have to add a keyboard_response anymore (but do use a logger!).

  • edited 2:43PM

    Thanks Edwin, I'll give it a try. This is my first go at programming anything.

  • edited October 2012

    Hi Edwin,

    When I insert the script, I get the following error:

    Error: Script error
    Description: Error parsing variable definition: 'set font_family "mono" from openexp.keyboard import keyboard # timeout in milliseconds maxtime = 3000 # list of allowed keys allowedkeys = ['return', 'space', 'k', ';', '9', 'right'] # create keyboard object my_keyboard = keyboard(self.experiment, keylist=allowedkeys, timeout=0) # wait for keyboard response or timeout no_timeout = True no_response = True starttime = self.experiment.time() while no_timeout: if no_response: pressed, presstime = my_keyboard.get_key() if pressed: self.experiment.set("response", my_keyboard.to_chr(pressed)) self.experiment.set("response_time", presstime - starttime) no_response = False if self.experiment.time() - starttime >= maxtime: if no_response: self.experiment.set("response", 'timeout') self.experiment.set("response_time", None) no_timeout = False '
    

    I'm unclear what this means. (Again, I'm not a script person!)
    Thank you for any help!

  • edited October 2012

    It seems that you have pasted the script into the OpenSesame script that defines an item, rather than a Python inline_script item (for an explanation of the difference, see here).

    Is that correct? If so, could you try it again, but this time add a new inline_script item to the experiment, and paste the code into the editor of this item?

    Cheers!

  • edited 2:43PM

    Thank you Sebastian!

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