Skip to content

Commit c470226

Browse files
authored
Update search.mdx
1 parent 4090b69 commit c470226

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

fern/docs/pages/plug-sdk/web/search.mdx

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -90,28 +90,24 @@ You can bind the `toggleSearchAgent` method to a hotkey, such as `Cmd + K` (or `
9090
```
9191
</Tab>
9292

93-
```
94-
</Tab>
9593
<Tab title="Setup for React">
96-
9794
```jsx
9895
useEffect(() => {
99-
const handleKeyDown = event => {
100-
if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "k") {
101-
event.preventDefault(); // Prevent default behavior
102-
window.plugSDK.toggleSearchAgent();
103-
}
104-
};
105-
// Attach the event listener
106-
document.addEventListener("keydown", handleKeyDown);
107-
// Clean up the event listener on unmount
108-
return () => {
109-
document.removeEventListener("keydown", handleKeyDown);
110-
};
111-
}, []);
96+
const handleKeyDown = event => {
97+
if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "k") {
98+
event.preventDefault(); // Prevent default behavior
99+
window.plugSDK.toggleSearchAgent();
100+
}
101+
};
102+
// Attach the event listener
103+
document.addEventListener("keydown", handleKeyDown);
104+
// Clean up the event listener on unmount
105+
return () => {
106+
document.removeEventListener("keydown", handleKeyDown);
107+
};
108+
}, []);
112109
```
113110
</Tab>
114-
115111
</Tabs>
116112

117113
You can modify the keydown event listener to bind other key or keys combinations, or any other user event based on your application's needs.

0 commit comments

Comments
 (0)