Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Keyboard navigation for Trove newspapers
// ==UserScript==
// @name Trove newspapers keyboard navigation
// @namespace http://timsherratt.org/trove-keyboard-navigation
// @version 0.1
// @description Use left and right arrows to move between pages, up and down arrows to move between issues.
// @author Tim Sherratt (@wragge)
// @match https://trove.nla.gov.au/newspaper/page/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
let prev_page = document.querySelector('a[title="Prev page"]').href;
let next_page = document.querySelector('a[title="Next page"]').href;
let prev_issue = document.querySelector('a[title="Prev issue"]').href;
let next_issue = document.querySelector('a[title="Next issue"]').href;
document.onkeydown = checkKey;
function checkKey(e) {
e = e || window.event;
if (e.keyCode == '38') {
// up arrow
window.open(prev_issue, '_self');
}
else if (e.keyCode == '40') {
// down arrow
window.open(next_issue, '_self');
}
else if (e.keyCode == '37') {
// left arrow
window.open(prev_page, '_self');
}
else if (e.keyCode == '39') {
// right arrow
window.open(next_page, '_self');
}
}
})();
@wragge

This comment has been minimized.

Copy link
Owner Author

@wragge wragge commented Jan 24, 2021

Keyboard navigation for Trove newspapers!

This is a very simple script that does something very useful. It allows you to use the arrows on your keyboard to move between pages in Trove's digitised newspapers.

  • ⬆️ Up arrow – go to the first page of the previous issue
  • ⬇️ Down arrow – go the the first page of the next issue
  • ⬅️ Left arrow – go to the previous page
  • ➡️ Right arrow – go to the next page

This makes browsing through a newspaper much easier. Enjoy!

To install

Install the Tampermonkey browser extension. Then click on the 'Raw' button above. You'll be asked to confirm that you want to install this script. Just click on 'Install' – don't worry it's perfectly safe.

The next time you load a newspaper page in Trove, your arrow keys will be enabled.

To uninstall

You can temporarily disable the script at any time by clicking on the Tampermonkey icon in your browser's navigation bar and selecting the script from the drop down menu.

You can uninstall the script completely by opening up the Tampermonkey dashboard and deleting the script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment