1 /* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
2 * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
3 * text of the license. */
4 // @require: OpenLayers/Control.js
9 OpenLayers.Control.KeyboardDefaults = Class.create();
10 OpenLayers.Control.KeyboardDefaults.prototype =
11 Object.extend( new OpenLayers.Control(), {
19 initialize: function() {
20 OpenLayers.Control.prototype.initialize.apply(this, arguments);
27 Event.observe(document,
29 this.defaultKeyDown.bind(this));
35 defaultKeyDown: function (evt) {
37 var slide = this.map.getResolution() * this.slideFactor;
38 var center = this.map.getCenter();
40 var newCenter = center.copyOf();
44 newCenter = newCenter.add( -slide, 0);
47 newCenter = newCenter.add( slide, 0);
50 newCenter = newCenter.add( 0, slide);
53 newCenter = newCenter.add( 0, -slide);
57 if (!newCenter.equals(center)) {
58 this.map.setCenter(newCenter);
63 /** @final @type String */
64 CLASS_NAME: "OpenLayers.Control.KeyboardDefaults"