Example #1
0
func onKey(window *glfw.Window, k glfw.Key, s int, action glfw.Action, mods glfw.ModifierKey) {
	if action != glfw.Press {
		return
	}

	switch glfw.Key(k) {
	case glfw.KeyEscape:
		window.SetShouldClose(true)
	default:
		return
	}
}
func onKey(window *glfw.Window, k glfw.Key, s int, action glfw.Action, mods glfw.ModifierKey) {
	if action != glfw.Press {
		return
	}

	// disable if event handlers are flagged off
	if birdCollided && (k != glfw.KeyEscape) {
		return
	}

	switch glfw.Key(k) {
	case glfw.KeyEscape:
		window.SetShouldClose(true)
	case glfw.KeySpace:
		jump()
	default:
		return
	}
}
Example #3
0
func (e *EventHandler) GetKey(code KeyCode) Action {
	return Action(e.window.GetKey(glfw.Key(code)))
}