Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Prefer checking `which` property over `keyCode`

  • Loading branch information...
commit 92028fee52ff07e47c63c1d3bc9c00af15cd823e 1 parent 63f370f
@timoxley authored
Showing with 4 additions and 1 deletion.
  1. +4 −1 index.js
View
5 index.js
@@ -11,7 +11,10 @@ var has = ({}).hasOwnProperty
* @api public
*/
exports = module.exports = function(searchInput) {
- if ('object' === typeof searchInput && searchInput && has.call(searchInput, 'keyCode')) searchInput = searchInput.keyCode
+ if (searchInput && 'object' === typeof searchInput) {
+ var hasKeyCode = searchInput.which || searchInput.keyCode || searchInput.charCode
+ if (hasKeyCode) searchInput = hasKeyCode
+ }
if ('number' === typeof searchInput) return names[searchInput]
var search = String(searchInput)
var foundNamedKey = codes[search.toLowerCase()]
Please sign in to comment.
Something went wrong with that request. Please try again.