Translations of this page:
 

Continue by Pressing a Key

Sometimes, the keyboard should be used: for instance, in laboratory studies for navigating the questionnaire or to exclude participants from a study for methodological reasons if they do not have a keyboard.

JavaScript can directly react to inputs in the questionnaire and also to a keypress via the “keyup” event. The following HTML/JavaScript code hides the “Next” button but allows navigation to the next page by pressing the spacebar (keyCode 32).

<script type="text/javascript">
// Hide the "Next" button
SoSciTools.submitButtonsHide();
// React to the "keyup" event
window.addEventListener("keyup", function(e) {
    if (e.keyCode == 32){
        SoSciTools.submitPage();
    }
});
</script>

You can find the KeyCodes for other keys listed on numerous websites or test them directly at https://www.toptal.com/developers/keycode.

en/create/script-keys.txt · Last modified: 24.01.2025 17:42 by sema.altunoglu
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
Driven by DokuWiki