- Posts: 19
- Thank you received: 1
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Key shortcuts for question navigation
- yannickberger
- Topic Author
- Offline
- New Member
Less
More
5 years 9 months ago #170416
by yannickberger
Key shortcuts for question navigation was created by yannickberger
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
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
The topic has been locked.
- urbana
- Offline
- Premium Member
Less
More
- Posts: 90
- Thank you received: 17
5 years 9 months ago - 5 years 9 months ago #170418
by urbana
Replied by urbana on topic Key shortcuts for question navigation
Hi sure, you can bind an event to the combination and trigger the button:
I tested it, it should work
Code:
<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: 5 years 9 months ago by urbana.
The following user(s) said Thank You: yannickberger
The topic has been locked.
- yannickberger
- Topic Author
- Offline
- New Member
Less
More
- Posts: 19
- Thank you received: 1
5 years 9 months ago #170424
by yannickberger
Replied by yannickberger on 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 ?
This will apply to current survey so I need to put it in my theme : for instance in custom.js am I right ?
The topic has been locked.
- urbana
- Offline
- Premium Member
Less
More
- Posts: 90
- Thank you received: 17
5 years 9 months ago #170425
by urbana
Replied by urbana on 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
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
The topic has been locked.
- yannickberger
- Topic Author
- Offline
- New Member
Less
More
- Posts: 19
- Thank you received: 1
5 years 9 months ago #170426
by yannickberger
Replied by yannickberger on 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
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
The topic has been locked.
- urbana
- Offline
- Premium Member
Less
More
- Posts: 90
- Thank you received: 17
5 years 9 months ago #170427
by urbana
Replied by urbana on 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
You can rewrite the script to alert(e.which) to get the number of the key when you press CTRL+N on your keyboard
The topic has been locked.
- yannickberger
- Topic Author
- Offline
- New Member
Less
More
- Posts: 19
- Thank you received: 1
5 years 9 months ago #170431
by yannickberger
Replied by yannickberger on topic Key shortcuts for question navigation
Attachments:
The topic has been locked.