diff pics2/np_keys.js @ 56:0249782e231e

pics2: add np_keys and selected thumbnail anchoring
author paulo
date Tue, 10 Sep 2013 01:04:24 -0700
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/pics2/np_keys.js	Tue Sep 10 01:04:24 2013 -0700
     1.3 @@ -0,0 +1,23 @@
     1.4 +function getKeypress(e) {
     1.5 +	c = null
     1.6 +
     1.7 +	if (e.which == null)
     1.8 +		c = String.fromCharCode(e.keyCode);   // IE
     1.9 +	else if (e.which != 0 && e.charCode != 0)
    1.10 +		c = String.fromCharCode(e.which);     // All others
    1.11 +
    1.12 +	if (c != null) {
    1.13 +		if (c == 'n')
    1.14 +			goHref('next');
    1.15 +		else if (c == 'p')
    1.16 +			goHref('prev');
    1.17 +		else if (c == 'u')
    1.18 +			goHref('up');
    1.19 +	}
    1.20 +}
    1.21 +
    1.22 +function goHref(id) {
    1.23 +	window.location.href = document.getElementById(id).href;
    1.24 +}
    1.25 +
    1.26 +document.onkeypress = getKeypress