使用代码
import hotkeys from 'hotkeys-js'
hotkeys('command+s', function (event, handler) {
// 阻止窗体自带事件
event.preventDefault()
alert('you pressed command+s!')
})
本文介绍如何使用hotkeys-js库来监听并拦截特定的键盘快捷键操作,例如通过监听Command+S组合键来替代浏览器默认保存行为。
使用代码
import hotkeys from 'hotkeys-js'
hotkeys('command+s', function (event, handler) {
// 阻止窗体自带事件
event.preventDefault()
alert('you pressed command+s!')
})
522
2185

被折叠的 条评论
为什么被折叠?