diff options
author | Aylur <[email protected]> | 2025-01-01 19:48:13 +0100 |
---|---|---|
committer | Aylur <[email protected]> | 2025-01-01 19:48:13 +0100 |
commit | d6c3c9c179eba0c9536a1beaaeb0525a63e752f3 (patch) | |
tree | 2aab87da07f6b52b48e38b0f44c615c0953a9fd2 /docs | |
parent | f2244c20f4a6018bdb7a5ff605cdf7047af4aa18 (diff) |
docs(faq): how to register keybindings
close #223
Diffstat (limited to 'docs')
-rw-r--r-- | docs/guide/typescript/faq.md | 30 | ||||
-rw-r--r-- | docs/package.json | 2 |
2 files changed, 31 insertions, 1 deletions
diff --git a/docs/guide/typescript/faq.md b/docs/guide/typescript/faq.md index 1d08824..132900a 100644 --- a/docs/guide/typescript/faq.md +++ b/docs/guide/typescript/faq.md @@ -269,3 +269,33 @@ class MyWidget extends Widget.Box { } } ``` + +## How do I register keybindings? + +If you want global keybindings use your compositor. +Only **focused** windows can capture events. To make a window +focusable set its keymode. + +::: code-group +```tsx [gtk3] +<window + keymode={Astal.Keymode.ON_DEMAND} + onKeyPressEvent={(self, event: Gdk.Event) => { + if (event.get_keyval()[1] === Gdk.KEY_Escape) { + self.hide() + } + }} +/> +``` + +```tsx [gtk4] +<window + keymode={Astal.Keymode.ON_DEMAND} + onKeyPressed={(self, keyval) => { + if (keyval === Gdk.KEY_Escape) { + self.hide() + } + }} +/> +``` +::: diff --git a/docs/package.json b/docs/package.json index ad76c9a..e01b189 100644 --- a/docs/package.json +++ b/docs/package.json @@ -12,7 +12,7 @@ "vue": "^3.4.38" }, "scripts": { - "dev": "vitepress dev", + "dev": "vitepress dev --open", "build": "vitepress build", "preview": "vitepress preview", "vitepress": "vitepress", |