[OpenLayers-Commits] r12104 - trunk/openlayers/examples

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Fri Jun 17 17:10:16 EDT 2011


Author: tschaub
Date: 2011-06-17 14:10:15 -0700 (Fri, 17 Jun 2011)
New Revision: 12104

Modified:
   trunk/openlayers/examples/draw-undo-redo.js
Log:
Fix example to work where there is a metaKey but ctrl is used for undo/redo.

Modified: trunk/openlayers/examples/draw-undo-redo.js
===================================================================
--- trunk/openlayers/examples/draw-undo-redo.js	2011-06-17 18:59:16 UTC (rev 12103)
+++ trunk/openlayers/examples/draw-undo-redo.js	2011-06-17 21:10:15 UTC (rev 12104)
@@ -20,37 +20,26 @@
 draw.activate();
 
 OpenLayers.Event.observe(document, "keydown", function(evt) {
-    var code = evt.keyCode;
     var handled = false;
-    if (code === 90) {
-        // z
-        if ("metaKey" in evt) {
-            if (evt.metaKey) {
+    switch (evt.keyCode) {
+        case 90: // z
+            if (evt.metaKey || evt.ctrlKey) {
                 draw.undo();
                 handled = true;
             }
-        } else if (evt.ctrlKey) {
-            draw.undo();
-            handled = true;
-        }
-    }
-    if (code === 89) {
-        // y
-        if ("metaKey" in evt) {
-            if (evt.metaKey) {
+            break;
+        case 89: // y
+            if (evt.metaKey || evt.ctrlKey) {
                 draw.redo();
                 handled = true;
             }
-        } else if (evt.ctrlKey) {
-            draw.redo();
+            break;
+        case 27: // esc
+            draw.cancel();
             handled = true;
-        }
+            break;
     }
     if (handled) {
         OpenLayers.Event.stop(evt);
     }
-    if (code === 27) {
-        // esc
-        draw.cancel();
-    }
 });
\ No newline at end of file



More information about the Commits mailing list