Skip to content

Commit f15a885

Browse files
authored
Update search.mdx
1 parent 5d7980f commit f15a885

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,42 +71,44 @@ Once the widget is installed on your website, every user who visits your website
7171

7272
After integrating the PLuG widget, you can personalize and contextualize customer engagement. Learn how to [identify your customers](./user-identity) and update their information.
7373

74-
## Bind hotkey to toggleSearchAgent
74+
## Bind a hotkey to toggle search agent
7575

76-
You can bind the `toggleSearchAgent` method to a hotkey, such as `Cmd + K` (or `Ctrl + K` for Windows), to toggle the search agent quickly. Here's an example implementation:
76+
You can bind the `toggleSearchAgent` method to a hotkey, such as `Cmd + K` (or `Ctrl + K` for Windows), to toggle the search agent. Here's an example implementation:
7777

7878
<Tabs>
7979
<Tab title="Setup">
8080
```html
8181
<script>
8282
// Bind Cmd+K (or Ctrl+K) to toggle the search agent
83-
document.addEventListener('keydown', function (event) {
84-
if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === 'k') {
83+
document.addEventListener("keydown", function (event) {
84+
if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "k") {
8585
event.preventDefault(); // Prevent default behavior
8686
window.plugSDK.toggleSearchAgent();
8787
}
8888
});
8989
</script>
90+
```
91+
</Tab>
9092

9193
```
9294
</Tab>
9395
<Tab title="Setup for React">
9496
9597
```jsx
9698
useEffect(() => {
97-
const handleKeyDown = (event) => {
98-
if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === 'k'){
99+
const handleKeyDown = event => {
100+
if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "k") {
99101
event.preventDefault(); // Prevent default behavior
100102
window.plugSDK.toggleSearchAgent();
101103
}
102104
};
103105
// Attach the event listener
104-
document.addEventListener('keydown', handleKeyDown);
106+
document.addEventListener("keydown", handleKeyDown);
105107
// Clean up the event listener on unmount
106108
return () => {
107-
document.removeEventListener('keydown', handleKeyDown);
109+
document.removeEventListener("keydown", handleKeyDown);
108110
};
109-
}, []);
111+
}, []);
110112
```
111113
</Tab>
112114

0 commit comments

Comments
 (0)