Skip to content

Commit d2a7229

Browse files
committed
Highlight kbd elements on '?' press
1 parent 3ff7798 commit d2a7229

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

app/app.vue

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,20 @@ function handleGlobalKeydown(e: KeyboardEvent) {
5959
6060
router.push('/search')
6161
}
62+
63+
if (e.key === '?') {
64+
e.preventDefault()
65+
const kbdElements = document.querySelectorAll('kbd')
66+
for (const kbd of kbdElements) {
67+
kbd.classList.remove('kbd-highlight')
68+
kbd.classList.add('kbd-highlight')
69+
}
70+
setTimeout(() => {
71+
for (const kbd of kbdElements) {
72+
kbd.classList.remove('kbd-highlight')
73+
}
74+
}, 700)
75+
}
6276
}
6377
6478
if (import.meta.client) {
@@ -81,3 +95,24 @@ if (import.meta.client) {
8195
<ScrollToTop />
8296
</div>
8397
</template>
98+
99+
<style>
100+
@keyframes kbd-highlight {
101+
0% {
102+
box-shadow: none;
103+
}
104+
15% {
105+
box-shadow: 0 0 4px 2px var(--accent);
106+
}
107+
60% {
108+
box-shadow: 0 0 4px 2px var(--accent);
109+
}
110+
100% {
111+
box-shadow: none;
112+
}
113+
}
114+
115+
kbd.kbd-highlight {
116+
animation: kbd-highlight 0.7s ease-out;
117+
}
118+
</style>

0 commit comments

Comments
 (0)