VUE3 TypeScript 支持监听 键盘事件

1 document.addEventListener("keyup", function(e) {
2   console.log("按键:", e.key)
3   if (e.key === "Escape") {
4     ClearMapTool()
5   }
6 })

 

直接使用document 的 keyup 事件, 只不过,这里用的是 e.key 而不是 e.keycode 。

另外如果不知道键对应的字符值,可以 console.log(e.key) 下来,查看下试试。

posted @ 2022-07-25 14:37  googlegis  阅读(2306)  评论(0编辑  收藏  举报

坐标合肥,非典型GIS开发人员 GitHub