Files
openlayers/lib/OpenLayers/Control/KeyboardDefaults.js
crschmidt a4c86b0489 Tag 2.3-RC3.
git-svn-id: http://svn.openlayers.org/tags/openlayers/release-2.3-rc3@2235 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2007-02-16 21:32:40 +00:00

57 lines
1.4 KiB
JavaScript

/* Copyright (c) 2006-2007 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/release-license.txt
* for the full text of the license. */
/**
* @class
*
* @requires OpenLayers/Control.js
*/
OpenLayers.Control.KeyboardDefaults = OpenLayers.Class.create();
OpenLayers.Control.KeyboardDefaults.prototype =
OpenLayers.Class.inherit( OpenLayers.Control, {
/** @type int */
slideFactor: 50,
/**
* @constructor
*/
initialize: function() {
OpenLayers.Control.prototype.initialize.apply(this, arguments);
},
/**
*
*/
draw: function() {
OpenLayers.Event.observe(document,
'keypress',
this.defaultKeyDown.bind(this));
},
/**
* @param {Event} evt
*/
defaultKeyDown: function (evt) {
switch(evt.keyCode) {
case OpenLayers.Event.KEY_LEFT:
this.map.pan(-50, 0);
break;
case OpenLayers.Event.KEY_RIGHT:
this.map.pan(50, 0);
break;
case OpenLayers.Event.KEY_UP:
this.map.pan(0, -50);
break;
case OpenLayers.Event.KEY_DOWN:
this.map.pan(0, 50);
break;
}
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Control.KeyboardDefaults"
});