sheep-market

10.000 sheep created by online workers  https://p.ce9e.org/sheep-market/
git clone https://git.ce9e.org/sheep-market.git

commit
c2ed23980fe4467b5f3b540f35d93bed131a4679
parent
6b9786a31e5dc672f73396804714068619d33e1f
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2023-01-04 16:25
allow to move hover with keyboard

Diffstat

M sheep.js 21 +++++++++++++++++++++

1 files changed, 21 insertions, 0 deletions


diff --git a/sheep.js b/sheep.js

@@ -89,6 +89,27 @@ grid.addEventListener('mousemove', function(event) {
   89    89 	updateHover();
   90    90 });
   91    91 
   -1    92 grid.addEventListener('keydown', function(event) {
   -1    93 	var dx = 0;
   -1    94 	var dy = 0;
   -1    95 	if (event.code === 'ArrowUp' && hoverRow > 0) {
   -1    96 		dy = -1;
   -1    97 	} else if (event.code === 'ArrowRight' && hoverCol + 1 < columns) {
   -1    98 		dx = 1;
   -1    99 	} else if (event.code === 'ArrowDown' && hoverRow + 1 < rows) {
   -1   100 		dy = 1;
   -1   101 	} else if (event.code === 'ArrowLeft' && hoverCol > 0) {
   -1   102 		dx = -1;
   -1   103 	}
   -1   104 	if (dx || dy) {
   -1   105 		event.preventDefault();
   -1   106 		hoverCol += dx;
   -1   107 		hoverRow += dy;
   -1   108 		updateHover();
   -1   109 		gridHover.scrollIntoView();
   -1   110 	}
   -1   111 });
   -1   112 
   92   113 var q = parseQuery(location.search);
   93   114 var id = parseInt(q.sheep, 10);
   94   115 if (id) {