ProjectSidewalk / SidewalkWebpage

Project Sidewalk web page
http://projectsidewalk.org
MIT License
84 stars 25 forks source link

3612 Add keyboard shortcuts to gallery expanded view #3613

Closed jsomeara closed 2 months ago

jsomeara commented 3 months ago

Resolves #3612

I added keyboard shortcuts to the gallery expanded view (the view when one of the gallery cards/labels is clicked).

Here are the shortcuts I added:

I also made sure the keybindings for google street view (examples: W, A, S, D, arrow keys) were properly deactivated to avoid interference with the new keyboard shortcuts.

Please don't hesitate to let me know if something needs to be corrected!

Video

https://github.com/user-attachments/assets/f2f970fd-fbfb-4526-98fd-f871f66fcb39

Testing instructions
  1. Go to the gallery. Click any label and this will open the expanded view.
  2. Try pressing some keyboard shortcuts (the shortcuts added can be seen in the description of this PR)
  3. You can also see that after exiting the expanded view, the keyboard shortcuts shouldn't perform any actions
Things to check before submitting the PR
jsomeara commented 3 months ago

I made a dedicated file for the keyboard event listening called Keyboard.js. I also fixed the inline function declarations to match the style guide. Lastly, I added all of the logging necessary (I am yet to update the wiki page yet).

jsomeara commented 3 months ago

I made some changes to address the issues. The biggest one was restructuring the way the system worked. Instead of having a keybinding function, it centralizes the keybindings in the Keyboard.js file by using a switch statement.

Sorry for having that many commit messages! I didn't realize how many times I was committing even minor changes.

misaugstad commented 3 months ago

Sorry for having that many commit messages! I didn't realize how many times I was committing even minor changes.

No problem! I'd rather have commit messages that are two small over ones that are too large! And that line can be harder to find when you're making a bunch of misc changes from a PR review.

Hoping to take a look later today or tomorrow! :crossed_fingers:

jsomeara commented 2 months ago

Implemented the requested changes! I also caught an issue where it was unnecessarily spitting out error messages in the console when e.key was undefined. That's fixed now. Ready for review!