Skip to content
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

Is it possible to press and Hold key for x amount of seconds? #699

Open
1 of 3 tasks
kennethgargan opened this issue Nov 13, 2024 · 1 comment
Open
1 of 3 tasks

Comments

@kennethgargan
Copy link

  • Robotgo version (or commit ref): v0.110.5 (v1.0.0-rc4)
  • Go version: go1.21.2
  • Gcc version: 13.2.0
  • Operating system and bit: Windows 10 - 64 bit
  • Resolution: N/A
  • Can you reproduce the bug at Examples:
    • Yes (provide example code)
    • No
    • Not relevant
  • Provide example code:
package main

import (
	"fmt"

	"github.com/go-vgo/robotgo"
)

func main() {
	fmt.Println("Pressing a for 3 seconds")
	robotgo.KeyDown("a")
	robotgo.Sleep(3)
	robotgo.KeyUp("a")
}
  • Log gist:

Description

Hi, Is it possible to have it so I can press a key down for a certain amount of seconds? In the example code, I want to press a for 3 seconds before releasing the key but it doesn't seem to work.
Is there any way to go about doing this in RobotGo?

Thanks.

@drgrib
Copy link

drgrib commented Jan 11, 2025

I just tried this and it worked as expected. Note that I'm using some personal private packages with self-explanatory functionality:

package main

import (
	"github.com/drgrib/global_go/comp"
	"github.com/drgrib/global_go/mac"
	"github.com/go-vgo/robotgo"
)

func main() {
	comp.MustBeNil(mac.Activate("qFlipper"))
	robotgo.KeyDown("Up")
	robotgo.Sleep(3)
	robotgo.KeyUp("Up")
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants