File tree 1 file changed +8
-21
lines changed
1 file changed +8
-21
lines changed Original file line number Diff line number Diff line change 1
- <script context =" module" >
2
- // Pressing these keys will focus the search bar.
3
- const FOCUS_KEYS = new Set ([" /" , " Metak" ]);
4
- </script >
5
-
6
1
<script >
7
2
import {
8
3
isActive ,
47
42
const deprecated = [];
48
43
const new_components = [];
49
44
50
- let keys = " " ;
51
45
let value = " " ;
52
46
let active = false ;
53
47
$: results = miniSearch .search (value).slice (0 , 10 );
72
66
73
67
<svelte:body
74
68
on :keydown =" {(e ) => {
75
- keys += e .key ;
76
- }}"
77
- on :keyup =" {(e ) => {
78
69
if (active ) return ;
79
-
80
- if (FOCUS_KEYS .has (keys )) {
81
- if (
82
- document .activeElement instanceof HTMLInputElement ||
83
- document .activeElement instanceof HTMLTextAreaElement
84
- ) {
85
- // Exit early if an inputtable element is already focused.
86
- return ;
87
- }
88
-
70
+ if (
71
+ document .activeElement instanceof HTMLInputElement ||
72
+ document .activeElement instanceof HTMLTextAreaElement
73
+ ) {
74
+ // Exit early if an inputtable element is already focused.
75
+ return ;
76
+ }
77
+ if ((e .metaKey && e .key === ' k' ) || e .key === ' /' ) {
89
78
e .preventDefault ();
90
79
active = true ;
91
80
}
92
-
93
- keys = ' ' ;
94
81
}}" />
95
82
96
83
<Theme persist bind:theme =" {$theme }" >
You can’t perform that action at this time.
0 commit comments