1
/* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD
2
* license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the
3
* full text of the license. */
7
* @requires OpenLayers/Control.js
8
* @requires OpenLayers/Handler/Keyboard.js
12
* Class: OpenLayers.Control.KeyboardDefaults
15
* - <OpenLayers.Control>
17
OpenLayers.Control.KeyboardDefaults = OpenLayers.Class(OpenLayers.Control, {
20
* APIProperty: slideFactor
26
* Constructor: OpenLayers.Control.KeyboardDefaults
28
initialize: function() {
29
OpenLayers.Control.prototype.initialize.apply(this, arguments);
37
this.handler.destroy();
41
OpenLayers.Control.prototype.destroy.apply(this, arguments);
49
this.handler = new OpenLayers.Handler.Keyboard( this, {
50
"keydown": this.defaultKeyPress });
55
* Method: defaultKeyPress
56
* When handling the key event, we only use evt.keyCode. This holds
57
* some drawbacks, though we get around them below. When interpretting
58
* the keycodes below (including the comments associated with them),
59
* consult the URL below. For instance, the Safari browser returns
60
* "IE keycodes", and so is supported by any keycode labeled "IE".
62
* Very informative URL:
63
* http://unixpapa.com/js/key.html
68
defaultKeyPress: function (evt) {
70
case OpenLayers.Event.KEY_LEFT:
71
this.map.pan(-this.slideFactor, 0);
73
case OpenLayers.Event.KEY_RIGHT:
74
this.map.pan(this.slideFactor, 0);
76
case OpenLayers.Event.KEY_UP:
77
this.map.pan(0, -this.slideFactor);
79
case OpenLayers.Event.KEY_DOWN:
80
this.map.pan(0, this.slideFactor);
83
case 33: // Page Up. Same in all browsers.
84
var size = this.map.getSize();
85
this.map.pan(0, -0.75*size.h);
87
case 34: // Page Down. Same in all browsers.
88
var size = this.map.getSize();
89
this.map.pan(0, 0.75*size.h);
91
case 35: // End. Same in all browsers.
92
var size = this.map.getSize();
93
this.map.pan(0.75*size.w, 0);
95
case 36: // Home. Same in all browsers.
96
var size = this.map.getSize();
97
this.map.pan(-0.75*size.w, 0);
100
case 43: // +/= (ASCII), keypad + (ASCII, Opera)
101
case 61: // +/= (Mozilla, Opera, some ASCII)
102
case 187: // +/= (IE)
103
case 107: // keypad + (IE, Mozilla)
106
case 45: // -/_ (ASCII, Opera), keypad - (ASCII, Opera)
107
case 109: // -/_ (Mozilla), keypad - (Mozilla, IE)
108
case 189: // -/_ (IE)
109
case 95: // -/_ (some ASCII)
115
CLASS_NAME: "OpenLayers.Control.KeyboardDefaults"