Documentation ¶
Index ¶
Constants ¶
const PollingRate = 12 * time.Millisecond
Variables ¶
var IsKeyJustPressed = inpututil.IsKeyJustPressed
var IsKeyPressed = ebiten.IsKeyPressed
Functions ¶
func KeysToNames ¶ added in v0.3.1
func ToVirtualKey ¶
See https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes for reference. Alt, Shift, and Control has 3 codes: overall, left and right. Order of ArrowKeys are different between Ebiten and Windows VK. Order of Page Up/Down are different between Ebiten and Windows VK. KeyNumpadEnter returns VK_RETURN, while main Enter returns the same. KeyReserved0 ~ KeyReserved3 are skipped. Supposed KeyContextMenu stands for Applications key, which is next to Right control Supposed KeyMeta Left and Right stands for Left and Right Windows key. Supposed KeyNumpadEqual returns VK_OEM_PLUS. I guess this is derived from Apple Keyboard.
Types ¶
type Key ¶
type Key = ebiten.Key
type Key int
const ( KeyA Key = iota KeyB KeyC KeyD KeyE KeyF KeyG KeyH KeyI KeyJ KeyK KeyL KeyM KeyN KeyO KeyP KeyQ KeyR KeyS KeyT KeyU KeyV KeyW KeyX KeyY KeyZ KeyAltLeft KeyAltRight KeyArrowDown KeyArrowLeft KeyArrowRight KeyArrowUp KeyBackquote KeyBackslash KeyBackspace KeyBracketLeft KeyBracketRight KeyCapsLock KeyComma KeyContextMenu KeyControlLeft KeyControlRight KeyDelete KeyDigit0 KeyDigit1 KeyDigit2 KeyDigit3 KeyDigit4 KeyDigit5 KeyDigit6 KeyDigit7 KeyDigit8 KeyDigit9 KeyEnd KeyEnter KeyEqual KeyEscape KeyF1 KeyF2 KeyF3 KeyF4 KeyF5 KeyF6 KeyF7 KeyF8 KeyF9 KeyF10 KeyF11 KeyF12 KeyHome KeyInsert KeyMetaLeft KeyMetaRight KeyMinus KeyNumLock KeyNumpad0 KeyNumpad1 KeyNumpad2 KeyNumpad3 KeyNumpad4 KeyNumpad5 KeyNumpad6 KeyNumpad7 KeyNumpad8 KeyNumpad9 KeyNumpadAdd KeyNumpadDecimal KeyNumpadDivide KeyNumpadEnter KeyNumpadEqual KeyNumpadMultiply KeyNumpadSubtract KeyPageDown KeyPageUp KeyPause KeyPeriod KeyPrintScreen KeyQuote KeyScrollLock KeySemicolon KeyShiftLeft KeyShiftRight KeySlash KeySpace KeyTab KeyReserved0 KeyReserved1 KeyReserved2 KeyReserved3 )
The order is consistent with Ebiten.
const KeyNone Key = -1
func NamesToKeys ¶
type KeyActionType ¶ added in v0.6.0
type KeyActionType int
const ( Idle KeyActionType = iota Hit Release Hold )
func KeyAction ¶
func KeyAction(last, current bool) KeyActionType
func KeyActions ¶ added in v0.6.0
func KeyActions(last, current []bool) []KeyActionType
type Keyboard ¶ added in v0.6.0
type Keyboard struct { KeyboardReader // contains filtered or unexported fields }
No additional adjustment for keyboard when offset has changed. Both music and keyboard cannot seek at precise position once they start.
type KeyboardAction ¶ added in v0.6.0
type KeyboardAction struct { Time int32 KeyActions []KeyActionType }
KeyboardAction is for handling keyboard states conveniently.
type KeyboardReader ¶ added in v0.6.0
type KeyboardReader struct {
// contains filtered or unexported fields
}
func NewKeyboardReader ¶ added in v0.6.0
func NewKeyboardReader(states []KeyboardState) KeyboardReader
func (KeyboardReader) IsEmpty ¶ added in v0.6.0
func (kb KeyboardReader) IsEmpty() bool
No worry of accessing with nil pointer. https://go.dev/play/p/B4Z1LwQC_jP
func (KeyboardReader) Output ¶ added in v0.6.0
func (kb KeyboardReader) Output() []KeyboardState
func (*KeyboardReader) Read ¶ added in v0.6.0
func (kb *KeyboardReader) Read(now int32) []KeyboardAction
func (*KeyboardReader) Tidy ¶ added in v0.6.0
func (kb *KeyboardReader) Tidy()
Tidy removes redundant states.
type KeyboardState ¶ added in v0.6.0
It is great to wrap a slice with a struct and name it in the singular form, as it ensures the slice is always handled in a packed form.