-
-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
doc: document the correct usage of X11 hotkey registration #17
Comments
I guess the support for Linux OS was not well enough. If the registered hotkey conflicts with an existing hotkey, it won't have any effect. Generally you can run this example and see if it works on your system: Lines 15 to 34 in a5dde31
|
I checked that my hotkeys (including SYSTEM, INPUT METHOD, IDE) are not conflicting. The sample also failed to run successfully. |
It might be useful if you could find a second device to test the environment. |
@wsy998 OK. Now I recall the issue on Linux systems. In general, Ubuntu maps multiple Mod keys to represent a single mod key. To be able to correctly register the key combination, you need figure out what is the correct underlying keycode combination for the platform. For example, a regular Ctrl+Alt+S should be registered as: Ctrl+Mod2+Mod4+S. This example works on my Ubuntu 20.04 (Ctrl+Alt+S): package main
import (
"fmt"
"golang.design/x/hotkey"
"golang.design/x/hotkey/mainthread"
)
func main() { mainthread.Init(fn) }
func fn() {
hk := hotkey.New([]hotkey.Modifier{hotkey.ModCtrl, hotkey.Mod2, hotkey.Mod4}, hotkey.KeyS)
err := hk.Register()
if err != nil {
return
}
fmt.Printf("hotkey: %v is registered\n", hk)
<-hk.Keydown()
fmt.Printf("hotkey: %v is down\n", hk)
<-hk.Keyup()
fmt.Printf("hotkey: %v is up\n", hk)
hk.Unregister()
fmt.Printf("hotkey: %v is unregistered\n", hk)
} |
OK,Let me try. |
How did you find the other mod keys that are mapped? |
I can’t use it,is it my problem? (system:ubuntu 22.04)
The text was updated successfully, but these errors were encountered: