Howdy, Stranger!

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

Supported by

[solved] OpenSesame virtual keyboard/numpad

edited March 2016 in OpenSesame

Hello!

In my experiment, I would like my participants to solve equations by clicking on an on-screen numpad.
Using the documentation (http://osdoc.cogsci.nl/2.8/python/keyboard/#keyboard.show_virtual_keyboard) I tried this in an inline scipt:

from openexp.keyboard import keyboard

my_keyboard = keyboard(self.experiment, keylist=['1', '2', '3'])
my_keyboard.show_virtual_keyboard(True)
response1, timestamp2 = my_keyboard.get_key()
response2, timestamp2 = my_keyboard.get_key()
my_keyboard.show_virtual_keyboard(False)

But nothing appears on the screen... In the 'keyboard.show_virtual_keyboard(visible=True)' function description it says that it does not work for all back-ends, but I tried all of them and it didn't work for any of them...

Does anyone knows how I can get an on-screen keyboard/numpad in OpenSesame?

Comments

  • edited 7:38AM

    Hi Merel,

    Right now the virtual keyboard is only applicable when running experiments on Android. What exactly do you want to do? Of course, you could implement something like an on-screen numpad with a bit of scripting.

    Cheers,
    Sebastiaan

  • edited March 2016

    Hi Sebastiaan,

    Thanks for your reaction! Ah, allright that explains why it didn't work. I have a new idea, maybe I can make it work by showing a numpad made out of butons a couple of times in a row, which gives the participants the 'illusion' of using a numpad. Because, it is not possible to press more than one button in the same widget right?

    Something like this:

    labelQuestion = widgets.label(form,text=equation)
    button0 = widgets.button(form, text='0', var='response')
    button1 = widgets.button(form, text='1', var='response')
    button2 = widgets.button(form, text='2', var='response')
    button3 = widgets.button(form, text='3', var='response')
    button4 = widgets.button(form, text='4', var='response')
    button5 = widgets.button(form, text='5', var='response')
    button6 = widgets.button(form, text='6', var='response')
    button7 = widgets.button(form, text='7', var='response')
    button8 = widgets.button(form, text='8', var='response')
    button9 = widgets.button(form, text='9', var='response')
    button_enter = widgets.button(form, text='enter', var='next')
    
    form.set_widget(labelQuestion, (0,0), colspan=4)
    
    form.set_widget(button0, (0,1))
    form.set_widget(button1, (1,1))
    form.set_widget(button2, (2,1))
    form.set_widget(button_enter, (3,1), rowspan = 2)
    form.set_widget(button3, (0,2))
    form.set_widget(button4, (1,2))
    form.set_widget(button5, (2,2))
    form.set_widget(button6, (0,3))
    form.set_widget(button7, (1,3))
    form.set_widget(button8, (2,3))
    form.set_widget(button9, (3,3))
    
    button_clicked = form._exec()
    
    
  • edited 7:38AM

    Hi Merel,

    Using a form to implement a numpad is not a bad idea!

    Because, it is not possible to press more than one button in the same widget right?

    Correct, but you can re-execute the form until the participant presses the enter button. And then you can use the return value of form._exec() to keep track of the response. I modified your script to illustrate the basic principle.

    Cheers!
    Sebastiaan

    from libopensesame import widgets
    
    form = widgets.form(exp, cols=[1,1,1,1], rows=[1,1,1,1],
        margins=(50,100,50,100), spacing=25)
    
    
    equation = '2 + 2 = ?'
    
    labelQuestion = widgets.label(form,text=equation)
    labelResponse = widgets.label(form,text='')
    button0 = widgets.button(form, text='0')
    button1 = widgets.button(form, text='1')
    button2 = widgets.button(form, text='2')
    button3 = widgets.button(form, text='3')
    button4 = widgets.button(form, text='4')
    button5 = widgets.button(form, text='5')
    button6 = widgets.button(form, text='6')
    button7 = widgets.button(form, text='7')
    button8 = widgets.button(form, text='8')
    button9 = widgets.button(form, text='9')
    button_enter = widgets.button(form, text='enter')
    
    form.set_widget(labelQuestion, (0,0), colspan=2)
    form.set_widget(labelResponse, (2,0), colspan=2)
    
    form.set_widget(button0, (0,1))
    form.set_widget(button1, (1,1))
    form.set_widget(button2, (2,1))
    form.set_widget(button_enter, (3,1), rowspan = 2)
    form.set_widget(button3, (0,2))
    form.set_widget(button4, (1,2))
    form.set_widget(button5, (2,2))
    form.set_widget(button6, (0,3))
    form.set_widget(button7, (1,3))
    form.set_widget(button8, (2,3))
    form.set_widget(button9, (3,3))
    
    var.response = ''
    while True:
        labelResponse.text = 'Response: %s' % var.response
        button_clicked = form._exec()
        if button_clicked == 'enter':
            break
        var.response = '%s%s' % (var.response, button_clicked)
    
  • edited 7:38AM

    Nice addition to show the participants their response! :) Maybe I should also add something that they can change their response if they accidentally press the wrong button, with a 'backspace' button or something like that. Otherwise it may be a bit confronting for them to see there response :)

  • edited 7:38AM

    Jeej adding an extra button and replace the while loop with this works :) :

    var.response = ''
    while True:
        labelResponse.text = 'Response: %s' % var.response
        button_clicked = form._exec()
    
        if button_clicked == 'enter':
            break
    
        if button_clicked == 'backspace':
            var.response = ''
        else:
            var.response = '%s%s' % (var.response, button_clicked)
    
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