summaryrefslogtreecommitdiff
path: root/docs/guide
diff options
context:
space:
mode:
authorAylur <[email protected]>2025-01-01 19:48:13 +0100
committerAylur <[email protected]>2025-01-01 19:48:13 +0100
commitd6c3c9c179eba0c9536a1beaaeb0525a63e752f3 (patch)
tree2aab87da07f6b52b48e38b0f44c615c0953a9fd2 /docs/guide
parentf2244c20f4a6018bdb7a5ff605cdf7047af4aa18 (diff)
docs(faq): how to register keybindings
close #223
Diffstat (limited to 'docs/guide')
-rw-r--r--docs/guide/typescript/faq.md30
1 files changed, 30 insertions, 0 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()
+ }
+ }}
+/>
+```
+:::