I use this code in my project, but keyboard.GetSingleKey() waiting keystroke. How to make the function not wait for a keypress and return nil (for example, after 1 second)?
package main
import (
"fmt"
"github.com/eiannone/keyboard"
)
func main() {
char, _, err := keyboard.GetSingleKey()
if (err != nil) {
panic(err)
}
fmt.Printf("You pressed: %q
", char)
}
If key was not pressed output "Key was not pressed",but in another case output "You pressed: " and key name