Key shortcuts for question navigation

More
2 months 3 weeks ago #170416 by yannickberger
yannickberger created the topic: Key shortcuts for question navigation
Hello everyone,
I am working with people with visual disabilities and for them it's very important to have to possibility to navigate with the keyboard.

So my question is it possible with Javascript to create key shortcuts to navigate within question blocks ?

For exemple if they press :

CTRL+N -> they go to the next question
CTRL+B -> they go back to last question

Any help would be much appreciated

Please Log in or Create an account to join the conversation.

More
2 months 3 weeks ago - 2 months 3 weeks ago #170418 by urbana
urbana replied the topic: Key shortcuts for question navigation
Hi sure, you can bind an event to the combination and trigger the button:
<script>
$( document ).ready(function() {
    $(document).keypress(function(e){
        if( e.which === 14 && e.ctrlKey ){
            $("#ls-button-submit").trigger('click');
        }
        else if( e.which === 2 && e.ctrlKey ){
            alert('control + b'); 
            //trigger here the id of a back button
        }          
    });
});
</script>

I tested it, it should work
Last Edit: 2 months 3 weeks ago by urbana.
The following user(s) said Thank You: LouisGac, yannickberger

Please Log in or Create an account to join the conversation.

More
2 months 3 weeks ago #170424 by yannickberger
yannickberger replied the topic: Key shortcuts for question navigation
Ok I manage to understand your code, but couldn't make it work properly.

This will apply to current survey so I need to put it in my theme : for instance in custom.js am I right ?

Please Log in or Create an account to join the conversation.

More
2 months 3 weeks ago #170425 by urbana
urbana replied the topic: Key shortcuts for question navigation
Yes an overall js should work.
I placed it for my test just in the helptext but that is of course not efficient.
I attached you my test survey so you can test it - back btns aren't active so CTRL-B doesn't work. But CTRL-N works.
You'll find the script in the help text of the first question and in the welcome text of the survey
Attachments:
The following user(s) said Thank You: yannickberger

Please Log in or Create an account to join the conversation.

More
2 months 3 weeks ago #170426 by yannickberger
yannickberger replied the topic: Key shortcuts for question navigation
I imported your survey and tried your to hit : ctrl+n at the description page and at the first question page but nothing happened.

I see your Survey was in German, so I assume you have a german keyboard maybe there is a difference with my Swiss(french) keyboard with the key.

I'll investigate but I got the main idea so thank's for help

Please Log in or Create an account to join the conversation.

More
2 months 3 weeks ago #170427 by urbana
urbana replied the topic: Key shortcuts for question navigation
That could be the case but does it differ that much?
You can rewrite the script to alert(e.which) to get the number of the key when you press CTRL+N on your keyboard

Please Log in or Create an account to join the conversation.

More
2 months 3 weeks ago #170431 by yannickberger
yannickberger replied the topic: Key shortcuts for question navigation
Ok I managed to make it work with this :



So now I just to adapt it to go forward and backwards and load it on all pages

Thanks for your help
Attachments:

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!