Skip to content

Commit

Permalink
Add lock shortcut
Browse files Browse the repository at this point in the history
  • Loading branch information
tiger2005 committed May 4, 2022
1 parent db0ca22 commit 90285fb
Show file tree
Hide file tree
Showing 9 changed files with 678 additions and 523 deletions.
17 changes: 16 additions & 1 deletion README-zh_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ npm rebuild --runtime=electron --target=12.0.0 --disturl=https://atom.io/downloa
| displayShortcut | boolean | 打开快捷键显示 |
| antiMinimize | boolean | 在尝试最小化时自动复原 |
| bounceTime | number | 一个按键弹起的毫秒数 |

| lockShortcut | object | 锁定的快捷键信息 |

一些细节如下:

**工具栏模式**:可以是“调试模式”(显示当前按键的键值)、“CPS 模式”(显示目前按下的按键次数和 CPS)和“仅统计模式”(只统计按键次数)。
Expand All @@ -84,6 +85,20 @@ npm rebuild --runtime=electron --target=12.0.0 --disturl=https://atom.io/downloa

**严格统计模式**:在模式下,只有在显示的按键范围中的字符会计入按键次数和 CPS。在这个模式下,`TOTAL` 将会换为 `S-TOTAL`

**锁定快捷键**:你需要使用以下参数配置快捷键:

```json
{
"id": "L", // 需要按下的按键对应的 ID
"shiftKey": true, // 是否按下 Shift
"ctrlKey": true, // 是否按下 Ctrl
"altKey": false, // 是否按下 Alt
"metaKey": false // 是否按下 Meta
}
```

上述例子表示的快捷键即为 `Ctrl + Shift + L`。在使用快捷键锁定或者解锁键盘的时候将会收到系统通知。

如果你使用默认设置,你将会得到一个亮色、无功能键盘。以下是暗色的配色方案:

```json
Expand Down
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,30 @@ This is a json file including all the function switchers and style settings. Key
| displayShortcut | boolean | Open shortcut key displayer |
| antiMinimize | boolean | Automately restore while minimizing the keyboard |
| bounceTime | number | Milliseconds for a key to bounce up |
| lockShortcut | object | Information of lock shortcut |

Some details below:

**Toolbar mode**: can be "debug mode" (display the key code you pressed), "cps mode" (calculate and display total press count and current cps) and "total mode" (only calculate and display press count).

**Heatmap brightness**: can be a number between -1.0 and 1.0. The closer the number is to -1.0, the lighter the colors will be. `light` and `dark` equals -0.4 and 0.5, respectively.
**Heatmap brightness**: can be a number between -1.0 and 1.0. The closer the number is to -1.0, the lighter the colors will be. `light` and `dark` are equal to -0.4 and 0.5, respectively.

**Strict count mode**: a mode that only the keys on the keyboard will be calculated into press count and cps. In this mode, `TOTAL` will change to `S-TOTAL`.

**Key shortcut**: you should use following arguments to initialize the shortcut:

```json
{
"id": "L", // The ID of the key
"shiftKey": true, // If Shift is needed to press
"ctrlKey": true, // If Ctrl is needed to press
"altKey": false, // If Alt is needed to press
"metaKey": false // If Meta is needed to press
}
```

The example above means `Ctrl + Shift + L`. If you use shortcut to lock / unlock the keyboard, you will receive a system message.

If you use default settings, you can get a light keyboard with no functions. Here is a color scheme for a dark keyboard:

```json
Expand Down
13 changes: 10 additions & 3 deletions asserts/options.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
{
"fontSize": 14,
"fontSize": 16,
"fontFamily": "Config, Monaco, Menlo, \"Ubuntu Mono\", Consolas, source-code-pro, monospace",
"alwaysOnTop": true,
"toolBarMode": "cps",
"toolBarFontSize": 14,
"keyCount": false,
"keyHeatmap": "none",
"keyTotalCountMode": "strict",
"displayShortcut": true,
"displayShortcut": false,
"antiMinimize": false,
"bounceTime": 200
"bounceTime": 200,
"lockShortcut": {
"id": "L",
"shiftKey": true,
"ctrlKey": true,
"altKey": false,
"metaKey": false
}
}
4 changes: 4 additions & 0 deletions css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ body {
display: inline-block;
}

.innerContent {
border-radius: 3px;
}

body > div > div{
-webkit-app-region: drag;
}
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
</div>
<div class="lockerMask closed">
<div style='display: flex; flex-direction: row; overflow: hidden; width: 100%;'>
<div style='width: calc(50% + 8px); text-align: right;'>
<div style='width: calc(50% + 8px); text-align: right;' class="lockContainer">
<i class="fas fa-lock"></i>
</div>
<div style='flex: 1; text-align: right; margin-right: 10px;' class="windowCloser">
Expand Down
14 changes: 12 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,22 @@ app.on('ready', function() {
mainWindow.loadURL('file://' + __dirname + '/index.html');
// mainWindow.openDevTools({mode: 'detach'});
mainWindow.setAlwaysOnTop(true);
if(process.platform === "win32")
mainWindow .hookWindowMessage(278, function(e) {
mainWindow.blur();
mainWindow.focus();
mainWindow.setEnabled(false);
setTimeout(() => {
mainWindow.setEnabled(true);
}, 100);
return true;
})
mainWindow.on('closed', function() {
mainWindow = null;
});
ipcMain.on('window-close', function() {
mainWindow.close();
})
mainWindow.close();
});
mainWindow.on('maximize', function () {
// mainWindow.webContents.send('main-window-max');
})
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Keyboard_Overlay",
"version": "0.1.1",
"version": "0.1.2",
"main": "main.js",
"dependencies": {
"app": "^0.1.0",
Expand All @@ -15,7 +15,7 @@
},
"build": {
"productName":"Keyboard_Overlay",
"appId": "Keyboard_Overlay",
"appId": "com.keyboard.overlay.app",
"copyright":"MIT",
"directories": {
"output": "build"
Expand Down
Loading

0 comments on commit 90285fb

Please sign in to comment.