Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #4 from BlogFrog/master

Close menu when [ESC] is pressed
  • Loading branch information...
commit 334cb3498e16d29905924b801e964c31692cd4ff 2 parents 3d1fe2f + e963cf0
@tj tj authored
Showing with 6 additions and 1 deletion.
  1. +6 −1 index.js
View
7 index.js
@@ -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, '-')
Please sign in to comment.
Something went wrong with that request. Please try again.