-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkeyMapWindow.html
More file actions
160 lines (142 loc) · 4.11 KB
/
keyMapWindow.html
File metadata and controls
160 lines (142 loc) · 4.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<head>
<style>
body * {
font-family: 'Montserrat', sans-serif;
}
body {
padding: 0;
margin: 0;
height: 100vh;
-webkit-user-select: none;
overflow: hidden;
}
.control-bar {
height: 32px;
font-size: 19px;
padding: 0 0 0 8px;
display: grid;
grid-template-columns: auto 1fr;
color: white;
background-color: #0d0d0d;
-webkit-app-region: drag;
align-items: center;
}
.content-wrapper {
display: flex;
justify-content: center;
width: 100%;
}
.info-wrapper {
display: flex;
flex-direction: column;
width: 100%;
height: 80px;
justify-content: space-around;
align-items: center;
}
#keyboard-name {
width: 70%;
height: 35px;
margin: 0 0 18px 0;
padding-left: 3.3px;
font-size: 1.2em;
background-color: #1f1f1f;
color: white;
border-style: none;
border: 2px solid #00000000;
border-radius: 3px;
box-shadow: 0px 0px 5px #00000088;
transition: 0.2s;
margin-top: 8px;
}
#keyboard-name:focus {
outline: none;
border: 2px solid #fff;
box-shadow: 1px 1px 5px rgba(0, 0, 0, 0.5);
}
.info {
display: flex;
/* flex-direction: row; */
justify-content: space-around;
width: 80%;
}
.info>span {
padding-left: 5px;
font-size: 1.2em;
background-color: #1f1f1f;
color: white;
border-radius: 3px;
width: 45%;
display: grid;
grid-template-columns: 60% 40%;
align-items: center;
}
.info>span>span {
background-color: #0d0d0d;
padding: 3.3px;
font-size: 1.2em;
border-radius: 3px;
text-align: center;
}
/* .keyboard-container {
display: flex;
width: 800px;
} */
.assign-key {
fill: green !important;
}
</style>
</head>
<body>
<div class="container">
<nav class="control-bar">
<strong class="title">New Keyboard</strong>
</nav>
<div class="content-wrapper">
<section class="info-wrapper">
<input type="text" id="keyboard-name" placeholder="Keyboard Name" required>
<div class="info">
<span id="char-dis">Character: <span>A</span></span>
<span id="code-dis">Key Code: <span>12</span></span>
</div>
</section>
</div>
<div id="keyboard-container">
</div>
</div>
</body>
<script>
let keyboard = localStorage.getItem('configuringKeyboard');
let saveKeyboard = localStorage.getItem('configuringKeyboard')
let container = document.getElementById('keyboard-container');
document.addEventListener('keydown', e => {
console.log(e);
})
container.innerHTML = keyboard;
let elementArray = container.children[0];
for(item of elementArray.childNodes) {
console.log(item)
item.addEventListener('click', (e) => {
e.stopPropagation();
makeActiveKey(e);
})
}
let activeKey;
function makeActiveKey(e) {
if(e.target != activeKey && activeKey) {
activeKey.classList.remove('assign-key');
}
let group = e.target.parentNode;
for(item of group.childNodes) {
if(item.nodeName != 'text') {
activeKey = item;
item.classList.add('assign-key', 'color-change')
}
}
}
document.addEventListener('click', (e) => {
if(e.target != activeKey) {
activeKey.classList.remove('assign-key');
}
})
</script>