New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Keyboard Handler #663
Keyboard Handler #663
Conversation
….keyboard.setZoomOffset and map.keyboard.setPanOffset can change the behavior of this handler.
Wow, this is awesome! Great work and really useful — will be merged for sure! Several suggestions:
|
…mOffset. Use these to configure how far the keyboard controls will pan/zoom the map (respectively).
…ke use of new focus events.
I've implemented the changes you requested including creating a
The underlying focus/blur functionality was achieved by following this article. Only tested so far on Mac OSX 10.5.8 running Chrome 18, Firefox 6 and Safari 5. More testing is appreciated. Hopefully this at least makes a decent start at issue #594. I also enabled map configuration options for |
@ericmmartinez Hi Eric, sorry for being slow about the pull... Going to merge this for 0.4. Could you please remove the Scale control fix? It was fixed in master in a simpler way, without the need to write custom calculation code. Also, it's a good practice to have a separate pull for each change so it can be discussed/acted upon independently. |
I've rolled back my changes to the L.Control.Scale so my pull request only includes the focus/keyboard stuff now. |
Awesome, thanks! |
Works like a charm, really great work Eric! I've cleaned up the code a bit to be more Leaflet-like, and also moved all Focus code to the Keyboard handler as I couldn't come up with a use case where you need focus but don't need keyboard navigation. |
Hey Eric, please take a look #869 — I guess it's safe to remove the 0 keycode? |
when i use the keyboard to pan the map, it doesn't work with the setMaxBounds. it keeps scrolling. is there a way to make it work ? |
@rostik known issue, will be fixed |
This implements a feature requested in issue #646.
Implementation tested in all browsers I have access to and I see no reason why it shouldn't work in additional browsers. The biggest obstacle is the event.keyCode for the various keys in different browsers. Implementation is done such that as new keyCodes are found in different browsers they can easily be supported by the handler. I would request additional browsers be tested. Not sure on the feasibility of support on mobile platforms.
Currently known to work on:
Mac OSX 10.6.8
Windows 7
Implementation adds a "keyboard" option for the L.Map configuration options. Default set to
true
, enables keyboard navigation when the most recent click was on the map. Can be set tofalse
to disable this navigation.Implementation supports variable panning distance and zoom level jumping by calling
setPanOffset
andsetZoomOffset
respectively. Both methods accept an integer parameter. In the former method the integer is the number of pixels to pan by when panning. In the latter offset the integer is the number of zoom levels to step in/out when zooming. Passing a negative integer to either method is supported and will effectively invert the controls. Note: A wrapper method could be added to the map for convenience. Currently a user would have to do something like the following to call these methods. (Seems unclean as-is)Default pan offset is 50 pixels. Default zoom offset is 1 zoom level.