Permalink
Browse files

Merge pull request #4 from BlogFrog/master

Close menu when [ESC] is pressed
  • Loading branch information...
2 parents 3d1fe2f + e963cf0 commit 334cb3498e16d29905924b801e964c31692cd4ff TJ Holowaychuk committed Oct 15, 2012
Showing with 6 additions and 1 deletion.
  1. +6 −1 index.js
View
@@ -83,6 +83,10 @@ Menu.prototype.unbindKeyboardEvents = function(){
Menu.prototype.onkeydown = function(e){
switch (e.keyCode) {
+ // esc
+ case 27:
+ this.hide();
+ break;
// up
case 38:
e.preventDefault();
@@ -98,7 +102,7 @@ Menu.prototype.onkeydown = function(e){
/**
* Focus on the next menu item in `direction`.
- *
+ *
* @param {String} direction "prev" or "next"
* @api public
*/
@@ -242,6 +246,7 @@ Menu.prototype.hide = function(){
*/
function createSlug(str) {
+ if (typeof str === 'number') { str = str.toString(); }
return str
.toLowerCase()
.replace(/ +/g, '-')

0 comments on commit 334cb34

Please sign in to comment.