// Listen start listening the keyboard events
func Listen() {

	// start the c code listeners to call the go function hook
	if isListening == false {

		ok := C.listen()

		if ok == 1 {
			err := errors.New("It was not possible to listen the global keyboard events, make sure to call the progam with 'sudo'")
			panic(err)
		}

		// change the flag to true to avoid entering this condition again
		isListening = true

	}

}
示例#2
0
func main() {
	fmt.Printf("listening...")
	C.listen()
}