annotate pics/np_keys.js @ 70:3456dd3e8660

myrss: add exception handling around main()
author paulo
date Wed, 29 Jul 2015 00:20:39 -0600
parents
children
rev   line source
paulo@25 1 function getKeypress(e) {
paulo@25 2 c = null
paulo@25 3
paulo@25 4 if (e.which == null)
paulo@25 5 c = String.fromCharCode(e.keyCode); // IE
paulo@25 6 else if (e.which != 0 && e.charCode != 0)
paulo@25 7 c = String.fromCharCode(e.which); // All others
paulo@25 8
paulo@25 9 if (c != null) {
paulo@25 10 if (c == 'n')
paulo@25 11 goHref('next');
paulo@25 12 else if (c == 'p')
paulo@25 13 goHref('prev');
paulo@25 14 else if (c == 'u')
paulo@25 15 goHref('up');
paulo@25 16 }
paulo@25 17 }
paulo@25 18
paulo@25 19 function goHref(id) {
paulo@25 20 window.location.href = document.getElementById(id).href;
paulo@25 21 }
paulo@25 22
paulo@25 23 document.onkeypress = getKeypress