Allows to navigate through links using the keyboard.
Author | HiEv |
Website | https://qjzhvmqlzvoo5lqnrvuhmg.on.drv.tw/UInv/Sample_Code.html#Keyboard%20Link%20Navigation |
Story format | SugarCube 2 |
Download | keyboard.zip |
If you want links to be automatically marked so that you can navigate them using the keyboard, you can use this script. Here are the keys you can use with this code:
If there is only one link in a passage, you can use the 1
or →
keys to go to the next passage.
If there are anywhere from 2 to 10 links in a passage, the links will get marked like this[1], and you can use the 0
through 9
keys to go to the corresponding passage. (📝 Note: In Opera you will need to have the page open in its own window with no other tabs on that window, otherwise the number keys will select which tab is visible in that window.)
If there are more than 10 links, the links will not be marked.
Keyboard navigation will be ignored if an <input>
element has focus.
The .
and r
keys will click a random link.
The ←
and `
keys can be used to go back a passage.
Also, in passages with a DisableKeyLinks
tag, no links will be marked and keyboard navigation will be disabled. You can use this tag for passages that need those keys for other things, such as passages with text input.
You can tag a passage with IgnoreArrowKeys
to disable just the ←
and →
keys for navigation in that passage. For example, you could use that tag on passages that need horizontal scrolling.
You can add a data-nokeys="true"
element to a link or a link's parent to have that link be ignored. For example:
<a data-nokeys="true" href="http://google.com">Google</a>
which displays as: Google
<span data-nokeys="true">[[Main Menu]]</span>
which displays as: Main Menu
Demo Twee code:
:: Start This demo is in a [[separate passage|Keyboard Link Navigation Example]] to avoid triggering it accidentally.