# aiv367-browser-hotkey **Repository Path**: magb/aiv367-browser-hotkey ## Basic Information - **Project Name**: aiv367-browser-hotkey - **Description**: 浏览器程序快捷键设置模块 - **Primary Language**: TypeScript - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2023-04-03 - **Last Updated**: 2023-04-03 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # aiv367-browser-hotkey #### 介绍 浏览器快捷键设置模块 #### Gitee [https://gitee.com/aiv367/aiv367-browser-hotkey](https://gitee.com/aiv367/aiv367-browser-hotkey) #### 示例 [http://aiv367.gitee.io/aiv367-browser-hotkey/demo](http://aiv367.gitee.io/aiv367-browser-hotkey/demo) #### 安装 ``` npm i aiv367-browser-hotkey --save ``` #### 使用 ```js import hotkey from 'aiv367-browser-hotkey'; // 注册执行命令 hotkey.addCMD('setBgColor', (color) => { document.body.style.backgroundColor = color; }); // 移除一个命令 // hotkey.removeCMD('setBgColor'); // 获取全部命令数据 // hotkey.getCMDs(); // 添加快捷键 F1 hotkey.addHotkey({ key: 'F1', ctrlKey: false, altKey: false, shiftKey: false, cmd: 'setBgColor("black")', des: '设置背景(black)' }); // 组合快捷键 Ctrl + F1 hotkey.addHotkey({ key: 'F1', ctrlKey: true, altKey: false, shiftKey: false, cmd: 'setBgColor("yellow")', des: '设置背景(yellow)' }); // 移除快捷键 // hotkey.removeHotkey(hotkey => hotkey.key === 'F1' && hotkey.ctrlKey); // 获取快捷键数据列表 // hotkey.getHotkeys(); // 启用禁用快捷键 // hotkey.config.enable = false; ```