summaryrefslogtreecommitdiff
path: root/examples/create-window/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'examples/create-window/main.go')
-rw-r--r--examples/create-window/main.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/examples/create-window/main.go b/examples/create-window/main.go
index 284daef..76df734 100644
--- a/examples/create-window/main.go
+++ b/examples/create-window/main.go
@@ -110,6 +110,16 @@ func main() {
// xproto.ChangeWindowAttributes (see l.50)).
// and reacts to it accordingly. All events are defined in the xproto subpackage.
switch ev.(type) {
+ case xproto.KeyPressEvent:
+ // See https://pkg.go.dev/github.com/jezek/[email protected]/xproto#KeyPressEvent
+ // for documentation about a key press event.
+ kpe := ev.(xproto.KeyPressEvent)
+ fmt.Printf("Key pressed: %d", kpe.Detail)
+ // The Detail value depends on the keyboard layout,
+ // for QWERTY, q is #24.
+ if kpe.Detail == 24 {
+ return // exit on q
+ }
case xproto.DestroyNotifyEvent:
return // Exit if we get a DestroyNotifyEvent.
}