Comments (6)
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
from hotkey.
I checked that my hotkeys (including SYSTEM, INPUT METHOD, IDE) are not conflicting. The sample also failed to run successfully.
from hotkey.
It might be useful if you could find a second device to test the environment.
from hotkey.
@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)
}
from hotkey.
OK,Let me try.
from hotkey.
How did you find the other mod keys that are mapped?
from hotkey.
Related Issues (20)
- [Windows] Unregister requires hotkey press to complete HOT 3
- BadAccess (X_GrabKey) when registering combination is obtained by others HOT 11
- Space key? HOT 1
- Linux hotkey can not be canceled correctly HOT 2
- Feature Request: Translate String to HotKey HOT 2
- ERROR: hotkey: xxx is registered HOT 6
- Question: Can other keys be used apart from the ones that hardcoded in library? HOT 6
- The official example on homepage doesn't work under M1 processor HOT 6
- Are there any ways to detect key holding press? HOT 5
- Command+Control combo on MacOS?
- Not working on Ubuntu 18? HOT 1
- Hotkey shortcut monitoring will hijack information
- Export Hotkeys
- Media Key support?
- Improve setup message
- Isolate OS runApp
- documentation HOT 5
- Allow unregister hotkeys HOT 6
- Allow listen on key up
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hotkey.