Howdy, Stranger!

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

Supported by

Presenting stimuli only while a button is pressed

edited September 2018 in OpenSesame

Hi to all,

I want to present a series of stimuli only while a certain button is pressed (i.e. the space button).
I already have the necessary part of the experiment for the presentation of the stimuli and the stimuli themselves.
Is there a way to do this?



  • Hi Amihai,

    There are multiple ways to do this, either with a script or coroutines item, but the easiest way depends on what you want to do exactly, and what you have programmed already. Could you upload the experiment here?


    Buy Me A Coffee

  • Hi Amihai,
    If you use an inline_script it may help to write a while loop, and ask for keylifts.
    You can find an example here:
    Good luck

  • Hi Sebastiaan, DahmSF,

    Thanks for the answers.

    Sebastiaan - I am attaching my experiment. Notice it is a bit "dirty" and has some scripts used for other purposes that I got from people in this forum (and for that I am grateful, I do not know how to code :smile: ). I want to add a script that will present the stimuli loop as long as the participant presses the space key. I would also appreciate advice on where to plant the script.

    DahmSF - I could not understand where is the example that you mentioned in the link you sent.

    Thanks again

  • Bump.
    Help anyone?

  • The example is in the experiment which is uploaded in the linked discussion. If you lift the button too early you get back to the beginning.
    --> There you need to keep the mouse button pressed, but you can easily change it to the space key on the keyboard.

  • DahmSF,

    I do not really know how to code so I cannot identify the specific part of the code that enables to present stimuli while a button is pressed. Can you point me to this part?
    Also, in my experiment, I measure the duration of the pressed button so it is a dependent variable. I do not want the experiment to go back to the beginning at any point. is the code in your example appropriate for this?


  • Hi Amihai,

    did you try the experiment i attached in the link?
    It contains not much more than pressing a button and keeping it pressed while some stimuli are presented.
    The duration you are asking for is easy to code. Just create a new variable: time of keylift - time of keypress.
    You can also look into the handbook for the keylift function Keyboard.get_key_release:

    Even if you do not want the experiment to go back to some point you need to specify what shall happen if a participant lifts the key too early. (I thought the best thing is to go back and start the trial again)

    You re welcome

  • Hi Stephan,

    I tried to take a look at the experiment but it did not work for me for some reason.
    I did look at the code in it though and saw that it is way above my level of understading.
    At this point, I think I will seek paid assistance.
    Do you know if there someone in this forum that offers such services?


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 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