Created
January 11, 2011 03:38
-
-
Save walterdavis/773978 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var current_selection = false; | |
//somewhere in your selection code, set this to | |
//true when you have marked a selection | |
// ... | |
current_selection = true; | |
var getKeyCode = function(evt){ | |
var code; | |
if (evt.keyCode) code = evt.keyCode; | |
else if (evt.which) code = evt.which; | |
return parseInt(code,10); | |
} | |
document.observe('keypress',function(evt){ | |
if(current_selection && getKeyCode(evt) == 32){ | |
//keep the event from doing anything to your form | |
evt.stop(); | |
$('yourMenu').show(); | |
//maybe cancel the global variable here, so you can | |
//once again type spaces | |
current_selection = false; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment