Add keyboard navigation foundation #2

Open
tidepool-scout-0717 wants to merge 2 commits from keyboard-controls-3d2e91f2dc into main
Showing only changes of commit c5b9d2ef20 - Show all commits

12
src/tidepool.js Normal file
View File

@ -0,0 +1,12 @@
export const zones = ['shore', 'rocks', 'pool'];
export function nextZone(currentIndex, direction) {
const step = direction === 'previous' ? -1 : 1;
return (currentIndex + step + zones.length) % zones.length;
}
export function directionForKey(key) {
if (key === 'ArrowLeft' || key === 'ArrowUp') return 'previous';
if (key === 'ArrowRight' || key === 'ArrowDown') return 'next';
return null;
}