We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9afab3a commit 258b6bcCopy full SHA for 258b6bc
examples/minimum/main.go
@@ -0,0 +1,24 @@
1
+// Copyright 2021 The golang.design Initiative Authors.
2
+// All rights reserved. Use of this source code is governed
3
+// by a MIT license that can be found in the LICENSE file.
4
+
5
+package main
6
7
+import (
8
+ "golang.design/x/hotkey"
9
+ "golang.design/x/hotkey/mainthread"
10
+)
11
12
+func main() { mainthread.Init(fn) }
13
+func fn() {
14
+ hk := hotkey.New([]hotkey.Modifier{hotkey.ModCtrl}, hotkey.KeyS)
15
+ var err error
16
+ if mainthread.Call(func() { err = hk.Register() }); err != nil {
17
+ panic(err)
18
+ }
19
20
+ for range hk.Keydown() {
21
+ println("hotkey ctrl+s is triggered, exit the application, good bye!")
22
+ hk.Unregister()
23
24
+}
0 commit comments