Need help: simple JS script for next page when right arrow key is pressed

this script should work - but it does nothing. where and how to put this code???
who can guide me :wink:

document.addEventListener(“keydown”, function(event) { if (event.keyCode === 39) { // 39 is the keyCode for the right arrow key var currentPage = location.href.substr(-6, 2); // get the current page number from the URL var nextPage = parseInt(currentPage.substr(-2)) + 1; // calculate the number of the next page if (nextPage < 10) { nextPage = “0” + nextPage; // add a leading zero if the next page number is less than 10 } location.href = location.href.substr(0, location.href.length - 6) + “text” + nextPage + “.html”; // set the URL of the next slide webpage } });