CloudMade/Leaflet — pull request #663 by ericmmartinez (2012-05-03 21:07:52+00:00)
Title: Keyboard Handler

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
- Safari 5.1.1
- Firefox 11
- Chrome 18

Windows 7
- IE 8
- IE 9
- Firefox 4
- Chrome 18

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 to ```false``` to disable this navigation.

Implementation supports variable panning distance and zoom level jumping by calling ```setPanOffset``` and ```setZoomOffset``` 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)

```
// Pan by 100 pixels when an arrow key is pressed
map.keyboard.setPanOffset(100);

// Zoom in/out 2 zoom levels when +/- is pressed.
map.keyboard.setZoomOffset(2);
```

Default pan offset is 50 pixels. Default zoom offset is 1 zoom level.