src/hg/js/jquery.contextmenu.js 1.3

1.3 2009/12/28 21:13:54 larrym
hide menu when user presses the escape key
Index: src/hg/js/jquery.contextmenu.js
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/js/jquery.contextmenu.js,v
retrieving revision 1.2
retrieving revision 1.3
diff -b -B -U 4 -r1.2 -r1.3
--- src/hg/js/jquery.contextmenu.js	13 Aug 2009 17:19:04 -0000	1.2
+++ src/hg/js/jquery.contextmenu.js	28 Dec 2009 21:13:54 -0000	1.3
@@ -219,8 +219,14 @@
 				}
 				$c.css( {top:pos.y+"px", left:pos.x+"px", position:"absolute",zIndex:9999} )[cmenu.showTransition](cmenu.showSpeed,((cmenu.showCallback)?function(){cmenu.showCallback.call(cmenu);}:null));
 				cmenu.shown=true;
 				$(document).one('click',null,function(){cmenu.hide()}); // Handle a single click to the document to hide the menu
+                                    $(document).one('keyup', null, function(event){
+                                     // hide menu when user presses the escape key
+                                    if (event.keyCode == 27) {
+                                        cmenu.hide();
+                                    }
+				});
 			}
 		},
 		
 		// Find the position where the menu should appear, given an x,y of the click event