Exemple #1
0
// GetKeyEX returns a bool indicating whether a key
// was pressed on the keyboard and a KeyboardInputInfo
// for what pressed. It does not block
// for input.
func GetKeyEX() (bool, KeyboardInputInfo) {
	value := KeyboardInputInfo{false, false, ' ', 0x00}

	fromC := C.GetKey()
	fromB := byte(fromC)

	if fromB == 0x00 {
		return false, value
	}

	value.KeyDown = true

	if fromB == ScEsc {
		value.IsSpecial = true
		value.SpecialChar = ScEsc
		return true, value
	}

	if fromB == ScIdentifier {
		value.IsSpecial = true
		value.SpecialChar = byte(C.GetKey())
		return true, value
	}

	value.Char = rune(fromC)

	return true, value
}
Exemple #2
0
// GetKey returns a bool indicating whether a key
// was pressed on the keyboard and a string for
// which character was pressed. It does not block
// for input.
func GetKey() (bool, string) {
	character := ""
	isHit := false
	fromC := C.GetKey()

	if byte(fromC) != 0x00 {
		character = C.GoStringN(&fromC, 1)
		isHit = true
	}

	return isHit, character
}