Skip to content

Commit

Permalink
Fixed the command key
Browse files Browse the repository at this point in the history
  • Loading branch information
andyhmltn committed Jan 19, 2015
1 parent 9d63c04 commit 1c1de16
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ You can also use multiple key combinations for the same callback. For example:

Version
----------
Quay is currently on version: `2.1.1`
Quay is currently on version: `2.1.2`

You can check the version at any time using the `Quay.VERSION` object. `Quay.VERSION.FULL()` will return the full version and `Quay.VERSION.[MAJOR/MINOR/PATCH]` is set to each value respectively.

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "quay",
"main": "quay.js",
"version": "2.1.1",
"version": "2.1.2",
"homepage": "https://github.com/andyhmltn/quay",
"authors": [
"Andy Hamilton <andyhmltn@gmail.com>"
Expand Down
31 changes: 22 additions & 9 deletions quay.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ var Quay = function($el) {
}
}
return false
},
remove = function(a, x) {
if (contains(a,x)) {
a.splice(a.indexOf(x),1 )
}
}

this.bindings = {}
Expand All @@ -28,7 +23,7 @@ var Quay = function($el) {
104: "8", 105: "9", 106: "*", 107: "+", 109: "-", 110: ".", 111 : "/",
112: "f1", 113: "f2", 114: "f3", 115: "f4", 116: "f5", 117: "f6", 118: "f7", 119: "f8",
120: "f9", 121: "f10", 122: "f11", 123: "f12", 144: "numlock", 145: "scroll", 186: "", 191: "/",
220: "\\", 222: "'", 224: "meta"
220: "\\", 222: "'", 224: "cmd", 17: "cmd", 93: "cmd"
}

this.convert = function(key) {
Expand All @@ -42,7 +37,10 @@ var Quay = function($el) {
}
this.run = function(key) {
var string = this.convert(key.which)
pressing.push(string)

if(! contains(string, pressing)) {
pressing.push(string)
}

pressing.sort()
}
Expand All @@ -66,7 +64,7 @@ var Quay = function($el) {
this.VERSION = {
MAJOR:2,
MINOR:1,
PATCH:1,
PATCH:2,
FULL :function() {
return this.MAJOR+'.'+this.MINOR+'.'+this.PATCH
}
Expand All @@ -87,7 +85,22 @@ var Quay = function($el) {
}

this.keyup = function(e) {
remove(pressing,_self.convert(e.which))
var key_string = _self.convert(e.which);

pressing = pressing.filter(function(value) {
return value !== key_string;
})

// The command key behaves extremely
// weirdly. It will cause the browser to
// 'forget' other keys are depressed and
// so the only way to deal with that is a
// hack to clear the keys pressed when cmd is
// released. Maybe not a correct assumption but
// it's better than breaking everything
if(key_string == "cmd") {
pressing = [];
}
}

this.bindTo = function($el) {
Expand Down

0 comments on commit 1c1de16

Please # to comment.