Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Show/hide links on keypress

I'm using Twine 2, and I'd like to allow players to press a key to show all links on a page. Links would be hidden by default. I've been trying to use Javascript to do this, but I'm having a difficult time figuring out what I can and can't do with Javascript in Twine 2.

Thanks for any help you can offer.

Comments

  • Forgot to say that I'm using Harlowe.
  • The only way I've come up with to do this is to hide the links with css, and then set up a keypress event which changes the link's css.

    Put this in the story's stylesheet
    tw-link {display: none;}
    

    And this in the story's javascript
    window.addEventListener("keypress", keypressed, false);
    
    function keypressed(e) {
    	var links = document.getElementsByTagName("tw-link");
    	var length = links.length;
    	for(var i = 0; i< length; i++)
    	{
    		links[i].style.display = "inline";
    	}
    }
    
Sign In or Register to comment.