Tweaking Hiev's keyboard link plugin

I’m using @Hiev’s keyboard link plugin for Sugarcube and it is working well.

I’d like to change it so that it can be toggled with a keypress (eg. the “tab” key). I see that it can already be enabled or disabled on particular passages when the author adds a tag, but I want to give the player the ability to toggle the feature.

Ideally this can be done without reloading the passage…I’m not sure if that is possible. If it’s necessary to reload the passage, I can work around that.

Unfortunately I am not very good with javascript…is @Hiev or anyone else able to to adapt it? Thanks in advance.

Twine Version: 1.x
Story Format: Sugarcube 2.x

I don’t know if it works for Twine 1 or Sugarcube version lower than 2.36 (Using Tweego/Twine2 + Sug 2.36.1), but I’ve made a setting toggle to display/hide the numbers:

Setting.addToggle("linkkeybindnumber", {
    label : "Numbered Links {Keybinding}<br>If enabled, you will see the corresponding number to press for each link on the passage (if there are more than one link).<br>Reload the page to see the changes.",
    default  : false,

And edit this part in the macro JavScript:

 if (n < 10) {
     if (settings.linkkeybindnumber) {
	$(" " + " <sup>[" + n + "]</sup>").appendTo(Links[i]);
      Links[i].id = "Link" + n;
 } else if (n === 10) {
	if (settings.linkkeybindnumber) {
		$(" " +" <sup>[0]</sup>").appendTo(Links[i]);
    	Links[i].id = "Link0";
} else {

You either need to reload the page/go to the next passage for it to work.

(It could be possible to make the setting toggle with Tab, but I have no idea how…)

1 Like

The tab key is not a good choice for something like this because it is used for keyboard navigation.

1 Like