Multicharacter keyboard input + German characters (Umlaute)
Hi @sebastiaan and all,
I have successfully managed to capture multicharacter keyboard responses in OSWeb using inline_javascript. However, some German characters cannot be inserted (namely: ä, ö, ü and ß).
Is there a way to extend my code to allow the participants to insert these characters or are the only allowed keys the ones listed in the available key list? Thanks for your help!
Best,
Cleo
Comments
Hi @Cleo,
I can't think of an easy solution for this, sorry. @sebastiaan or @eduard , do you have an idea?
Cheers,
Lotje
Did you like my answer? Feel free to

Hi @Cleo and @lvanderlinden ,
The only way I could think of doing this is by bypassing OSWeb altogether. The script below (and the attached experiment) shows how you can programmatically add a real HTML form, temporarily disable OSWeb, collect the input through the form, and the re-enable OSWeb again. This is actually a pretty promising approach that may be more generally useful to collect form input in OSWeb.
--- Sebastiaan
function accept_input() { // This function is called when the ok button is clicked. It makes // OSWeb visible again, restores the key handlers, hides the form, // and sets the form response as custom_form_input. custom_form.style.display = 'none' osweb.style.display = 'block' vars.custom_form_input = document.getElementById('input_text').value window.addEventListener('keydown', runner._events._keyDownHandler) window.addEventListener('keyup', runner._events._keyUpHandler) } // Create a div with a custom HTML form, and append it to the document let custom_form = document.createElement('div') custom_form.style = 'background-color: gray; height: 100%; text-align: center;' custom_form.innerHTML = '<h1>Hi there!</h1><input type="text" id="input_text"><input type="button" id="input_ok" value="ok">' document.body.append(custom_form) // Hide the element that shows the regular OSWeb content let osweb = document.getElementsByClassName('justify-content-center')[0] osweb.style.display = 'none'; // Remove the OSWeb key handlers, because otherwise OSWeb will keep responding // to the input to the form. window.removeEventListener('keydown', runner._events._keyDownHandler) window.removeEventListener('keyup', runner._events._keyUpHandler) // Call accept_input() when the Ok button is clicked document.getElementById('input_ok').onclick = accept_inputCheck out SigmundAI.eu for our OpenSesame AI assistant!
Hi Sebastian,
I am using your solution, and it works fine (thanks!), except when I use this script twice in a row (two inline_javascript) to get, say, the age and the nationality of participants. In that case, the first from input works fine, but then it freezes on the second one: the form appears as it should be, but nothing happens when I click on the "ok" button, so the experiment is stuck.
Any idea why is this happening ?
Thank you very much !
Hi again,
Just found it, had to rename the id's of the html form !
Thanks, Best !
HI @sebastiaan ,
I use this code for a memory experiment in Hebrew. In my experiment, this code appears in a loop, so the subjects could type few words, one by one, until the time is over.
It works great until I export the subjects results from JATOS. It looks like opensesame saved only the first word that was typed.
I can't get over it... the logger is in the correct place as well.
Maybe do you have some idea how can I solve this problem?
Thank you!
Hi @zohar ,
Could you upload the experiment here (or a simplified that illustrates the issue) so that I can take a look?
— Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Thank you!
@zohar Right, I see. I don't fully understand the structure of the experiment, i.e. what the two nested loops correspond to. But I suspect that the
loggershould be part of now_word_seq (and not recall_seq_1_2) so that it's executed after each time that a response is collected. Could that be it?Check out SigmundAI.eu for our OpenSesame AI assistant!
Hi,
Thank you for your answer.
I already tried it but it does not work... I also tried to delete one loop and leave just one.
@sebastiaan Hi again,
I tried to do few things and I think the problem is in the HTML code.
First, I changed the HTML code to a multichar response (typed in English) and the data was saved well.
Second, in the response loop there is also a rating scale and his data also saved correctly.
Maybe I need to change something in the HTML code to save all the words and not only one?
I have been working on this experiment for 4 months and am a little desperate ...
I am really appreciate your help,
Zohar.
@zohar I just released a test version of OSWeb 1.4. This provides much better support for text input (including non-Latin characters). This should allow you to simplify your experiment considerably, thus hopefully also resolving this issue.
Check out SigmundAI.eu for our OpenSesame AI assistant!