Skip to content
This repository was archived by the owner on Feb 16, 2025. It is now read-only.

Commit 0601b7f

Browse files
committed
update beta version
1 parent 9cc6f89 commit 0601b7f

File tree

12 files changed

+1039
-329
lines changed

12 files changed

+1039
-329
lines changed

WKE Standard.md

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
# Websocket Keyboard Event Standard
2+
3+
## Overview
4+
5+
This document defines a standard for the communication of keyboard events over a WebSocket connection.
6+
7+
## Terminology and Definitions
8+
9+
- **WebSocket** - A protocol for bidirectional communication between a client and a server.
10+
- **Keyboard Event** - An event that is dispatched by connected keyboards.
11+
- **Keyboard Event Payload** - The data sent by tarui backend.
12+
13+
### Key Definitions
14+
15+
TypeScript definitions of the key type.
16+
17+
```ts
18+
export enum Key {
19+
"Alt" = 0,
20+
"AltGr" = 1,
21+
"Backspace" = 2,
22+
"CapsLock" = 3,
23+
"ControlLeft" = 4,
24+
"ControlRight" = 5,
25+
"Delete" = 6,
26+
"DownArrow" = 7,
27+
"End" = 8,
28+
"Escape" = 9,
29+
"F1" = 10,
30+
"F10" = 11,
31+
"F11" = 12,
32+
"F12" = 13,
33+
"F2" = 14,
34+
"F3" = 15,
35+
"F4" = 16,
36+
"F5" = 17,
37+
"F6" = 18,
38+
"F7" = 19,
39+
"F8" = 20,
40+
"F9" = 21,
41+
"Home" = 22,
42+
"LeftArrow" = 23,
43+
// also known as windows = , super = , and command
44+
"MetaLeft" = 24,
45+
// also known as windows = , super = , and command
46+
"MetaRight" = 25,
47+
"PageDown" = 26,
48+
"PageUp" = 27,
49+
"Return" = 28,
50+
"RightArrow" = 29,
51+
"ShiftLeft" = 30,
52+
"ShiftRight" = 31,
53+
"Space" = 32,
54+
"Tab" = 33,
55+
"UpArrow" = 34,
56+
"PrintScreen" = 35,
57+
"ScrollLock" = 36,
58+
"Pause" = 37,
59+
"NumLock" = 38,
60+
"BackQuote" = 39,
61+
"Num1" = 40,
62+
"Num2" = 41,
63+
"Num3" = 42,
64+
"Num4" = 43,
65+
"Num5" = 44,
66+
"Num6" = 45,
67+
"Num7" = 46,
68+
"Num8" = 47,
69+
"Num9" = 48,
70+
"Num0" = 49,
71+
"Minus" = 50,
72+
"Equal" = 51,
73+
"KeyQ" = 52,
74+
"KeyW" = 53,
75+
"KeyE" = 54,
76+
"KeyR" = 55,
77+
"KeyT" = 56,
78+
"KeyY" = 57,
79+
"KeyU" = 58,
80+
"KeyI" = 59,
81+
"KeyO" = 60,
82+
"KeyP" = 61,
83+
"LeftBracket" = 62,
84+
"RightBracket" = 63,
85+
"KeyA" = 64,
86+
"KeyS" = 65,
87+
"KeyD" = 66,
88+
"KeyF" = 67,
89+
"KeyG" = 68,
90+
"KeyH" = 69,
91+
"KeyJ" = 70,
92+
"KeyK" = 71,
93+
"KeyL" = 72,
94+
"SemiColon" = 73,
95+
"Quote" = 74,
96+
"BackSlash" = 75,
97+
"IntlBackslash" = 76,
98+
"KeyZ" = 77,
99+
"KeyX" = 78,
100+
"KeyC" = 79,
101+
"KeyV" = 80,
102+
"KeyB" = 81,
103+
"KeyN" = 82,
104+
"KeyM" = 83,
105+
"Comma" = 84,
106+
"Dot" = 85,
107+
"Slash" = 86,
108+
"Insert" = 87,
109+
"KpReturn" = 88,
110+
"KpMinus" = 89,
111+
"KpPlus" = 90,
112+
"KpMultiply" = 91,
113+
"KpDivide" = 92,
114+
"Kp0" = 93,
115+
"Kp1" = 94,
116+
"Kp2" = 95,
117+
"Kp3" = 96,
118+
"Kp4" = 97,
119+
"Kp5" = 98,
120+
"Kp6" = 99,
121+
"Kp7" = 100,
122+
"Kp8" = 101,
123+
"Kp9" = 102,
124+
"KpDelete" = 103,
125+
"Function" = 104,
126+
"Unknown" = 105,
127+
}
128+
```
129+
130+
### Payload and Package Definitions
131+
132+
TypeScript definitions of the event payload and websocket package.
133+
134+
```ts
135+
export interface Payload {
136+
action: string
137+
key: Key
138+
}
139+
140+
export interface KeyboardEventPackage extends Payload {
141+
t: number
142+
}
143+
```
144+
145+
## Disclaimer
146+
147+
This standard don't be modified for other software, and just for the purpose of the project.

index.html

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,33 @@
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8" />
5-
<link rel="stylesheet" href="/src/styles.css" />
65
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7-
<title>Tauri App</title>
6+
<title>Keyboard Monitor</title>
7+
<style>
8+
html,
9+
body {
10+
padding: 0;
11+
margin: 0;
12+
}
13+
.app {
14+
width: calc(100% - 2px);
15+
height: calc(100vh - 2px);
16+
display: flex;
17+
justify-content: center;
18+
align-items: center;
19+
20+
font-family: Consolas, monospace;
21+
font-size: 16px;
22+
font-weight: 900;
23+
user-select: none;
24+
25+
border: 1px solid #000;
26+
}
27+
</style>
828
<script type="module" src="/src/main.ts" defer></script>
929
</head>
1030

1131
<body>
12-
<div id="app">
13-
<span class="prefix">[State]</span>
14-
<span class="state"></span>
15-
<span class="prefix">[Version]</span>
16-
<span class="version"></span>
17-
<span class="prefix">[Listen]</span>
18-
<span class="listen"></span>
19-
<span class="prefix d">[Display]</span>
20-
<span class="display"></span>
21-
</div>
32+
<div class="app" data-tauri-drag-region>Keyboard Monitor</div>
2233
</body>
2334
</html>

0 commit comments

Comments
 (0)