Howdy, Stranger!

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

Supported by

Moving Objects

Hello everyone!

I have you used Open Sesame -> OSWeb -> JATOS for one experiment already, and it worked perfectly.

I want to say thanks to all the contributors for working on this; it is highly appreciated! ๐Ÿ˜Š

Now I am trying to do something more complicated, and I encountered a couple of problems:

1: I am aware of the Timing limitations when looping Sketchpads in Sequences, but I was wondering, is there a way to go around that? For example, if I loop Sketchpads in Loops, there is no timing limitation, but I cannot have any other item inside. Can I somehow squeeze a bit of code inside of Loop or something similar?

2: Let's say I am creating a horizontally moving square at the top of the screen by manually putting Sketchpads one after the other in a Sequence. After a specific time, I make a target appear, and I want a person to react to it with a keyboard press WHILE the square still keeps moving. When playing with keyboard responses, I couldn't find a solution to it, it always had to wait for a keypress, and objects could not move while this was happening. Do you know a solution to this problem?




  • Hi Saša,


    The timing limitation only refers to transitions between prepare and run phases. So, even if there is a little code in the run phase (in between sketchpads) timing should largely be unaffected. But of course that depends on your specific experiment. So, either way, best to test your timing to know for sure.

    When playing with keyboard responses, I couldn't find a solution to it, it always had to wait for a keypress, and objects could not move while this was happening. Do you know a solution to this problem?

    Working with sketchpads and keyboard items this is indeed a bit tricky. I think it should be possible if you set the duration of the keyboard to some small value (< 5), and untick the box "Flash pending responses". This should essentially do the trick. However, it should be much easier to accomplish by applying a coding approach. Since the latest release, Opensesame supports quite a bit of javascript and interaction with canvases, etc. So you could essentially built a while loop (similar to your current loop), in which you update the position and visibility of your box and your target, while also polling key presses. This part of the documentation should be of particular interest to you.

    I hope this helps.


    Buy Me A Coffee

  • edited October 2021

    Hi @eduard,

    Thank you for your answer. I believe I will try to code everything instead of playing with the elements. It seems like a better approach, and the new release made it more accessible!

    I will post here in the next couple of days if I have any problems.



  • Hi @eduard

    It wasn't a problem to build a loop, but how to "poll key presses" in inline javascript?



  • Hi Saša,

    Oh sorry, I assumed the keyboard item would also be available in Osweb, but as far as I can see it isn't. However, there are some code snippets around in the forum that do collect responses. For example, see here:

    I haven't check the implementation though, so I can't tell you, whether it is applicable to your situation. You might be able to also use javascript event handlers, but how exactly, I don't know unfortunately. Perhaps @Fab can share his js wisdom? :)

    Good luck,


    Buy Me A Coffee

  • Hi @SaleSarma & @eduard,

    Can't really say I've achieved any wisdom in Javascript yet (only just begun to try to use it). Hopefully some day! ๐Ÿ˜‰

    I do not know whether you can create keyboard objects directly from Javascript within OSWeb. I think you can access and change a lot of stuff that features in browser's debugger if you can work out your way around it, but I'm not sure creating a keyboard object directly from code is possible (you might want to consult @sebastiaan on this).

    Digging around a little on the internet, I did come across something that might be of use to you, though I don't know how your task is actually set up, so maybe it isn't... There is a function in Javascript called addlistener that allows you to listen to a series of events (mouse clicks, keydown, keyup etc.).

    I think that sticking it into the loop presenting your stimuli might be a way to go:

    window.addEventListener('keydown', (event) => {
    // your code here

    I've had a quick go at trying it out with a task containing a loop running 1000 times and displaying a random number on the screen (just to see something happening on the screen; in your case I understand it would be an object being moved to a different position).

    I can get key presses detected and the key displayed on the screen, as well as the time stamp for the response. I tried to implement a response counter but for some reason that isn't working as I'd like (I think it might be because the code is executed so fast that pressing a response key probably generates not one but several consecutive keydown detection events and so the response counter is incremented multiple times in quick succession when a key is down). Might make it tricky to log the responses...

    Anyway... Don't know if that can be of help to you but that's what I could find out based on my limited experience with Javascript.



    Buy Me A Coffee

  • I'm not sure creating a keyboard object directly from code is possible 

    There is indeed currently no Keyboard object in JavaScript as there is in Python. If you want to implement custom key-press handling, the way to go is (as @Fab already pointed out) to implement a custom event listener for keydown events!

    Buy Me A Coffee

  • Hi @eduard, @Fab, and @sebastiaan,

    You have been of great help, and it works like a charm. Thank you very much!

    I have one more question that I didn't find a solution to, is there a way to play a simple sound (like a "beep") inside of an inline javascript?

  • @SaleSarma Yes. Assuming that there's a sound file called bark.ogg in the file pool, then you can play it like this:


    Buy Me A Coffee

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