Use Mousetrap lib for keyboard shortcuts for hopefully better handling of international keyboards

This commit is contained in:
Adam Wathan 2017-12-02 15:51:59 -05:00
parent 4a45a8b4fa
commit 0eb520927a
3 changed files with 9 additions and 5 deletions

View File

@ -1,5 +1,6 @@
const anchorJS = require('anchor-js')
const Prism = require('./prism')
const Mousetrap = require('mousetrap')
window.anchors = new anchorJS()
window.Vue = require('vue')
@ -15,8 +16,6 @@ anchors.options = { placement: 'left', class: 'text-slate-light' }
anchors.add()
// Add shortcut to search input when pressing the "/" key
document.onkeyup = function (e) {
if (e.which == 191) {
document.getElementById('docsearch').focus()
}
}
Mousetrap.bind('/', function (e) {
document.getElementById('docsearch').focus()
}, 'keyup')

View File

@ -45,6 +45,7 @@
"commander": "^2.11.0",
"fs-extra": "^4.0.2",
"lodash": "^4.17.4",
"mousetrap": "^1.6.1",
"nodemon": "^1.11.0",
"postcss": "^6.0.9",
"postcss-functions": "^3.0.0",

View File

@ -3035,6 +3035,10 @@ minimist@~0.0.1:
dependencies:
minimist "0.0.8"
mousetrap@^1.6.1:
version "1.6.1"
resolved "https://registry.yarnpkg.com/mousetrap/-/mousetrap-1.6.1.tgz#2a085f5c751294c75e7e81f6ec2545b29cbf42d9"
ms@2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"