Reputation: 2780
Is there a way to detect keypress only when the Google Maps canvas is in focus?
Google Maps JavaScript API V3 has built-in keyboard shortcuts. When a user clicks on a map tile or drags it, the map becomes in focus, and will respond to keyboard shortcuts. If you click anywhere else outside the map canvas, those keyboard shortcuts will no longer work.
I would like to extend some of these shortcuts (specifically the arrow keys) to perform additional actions.
Upvotes: 7
Views: 2486
Reputation: 111
You can disable the keyboard shortcuts in Google Maps like here
https://developers.google.com/maps/documentation/javascript/reference?hl=en#MapOptions
and then you can use the keyboard shortcuts for your own purposes.
Upvotes: 3