Documentation
¶
Index ¶
- type Keyboard
- func (k *Keyboard) ClearFrameConsumption()
- func (k *Keyboard) ForceLastKeyPressed(key ebiten.Key)
- func (k *Keyboard) GetAlphaNumericPressed() (*ebiten.Key, string)
- func (k *Keyboard) GetArrowKeyAsDirection() references.Direction
- func (k *Keyboard) GetBoundKeyPressed(boundKeys *[]ebiten.Key) *ebiten.Key
- func (k *Keyboard) GetKeyLetter(key ebiten.Key) string
- func (k *Keyboard) GetMsSinceLastKeyPress() int
- func (k *Keyboard) GetPressedArrowKey() *ebiten.Key
- func (k *Keyboard) GetPressedKey() *semantic_input.Key
- func (k *Keyboard) IsAnyKeyPressed() bool
- func (k *Keyboard) IsBoundKeyPressed(boundKeys *[]ebiten.Key) bool
- func (k *Keyboard) IsKeyHeld(key ebiten.Key) bool
- func (k *Keyboard) IsKeyPressedAndRegister(key ebiten.Key) bool
- func (k *Keyboard) IsKeyPressedAndRegisterRepeatable(key ebiten.Key) bool
- func (k *Keyboard) IsKeyPressedGetKey(key ebiten.Key) *ebiten.Key
- func (k *Keyboard) IsModifierComboPressed(modifier Modifier, key ebiten.Key) bool
- func (k *Keyboard) IsModifierPressed(modifier Modifier) bool
- func (k *Keyboard) IsNumberKeyPressedAndRegister() int
- func (k *Keyboard) IsTextKeyPressedAndRegister(key ebiten.Key) bool
- func (k *Keyboard) IsWaitingForRelease() bool
- func (k *Keyboard) PrepareForTransition(postAcceptDelayMs int)
- func (k *Keyboard) ResetReleaseDebouncing()
- func (k *Keyboard) SetAllowKeyPressImmediately()
- func (k *Keyboard) SetForceWaitAnyKey(ms int)
- func (k *Keyboard) SetLastKeyPressedNow()
- func (k *Keyboard) SetLastKeyPressedNowPlusMs(ms int)
- func (k *Keyboard) SimulateKeyPress(key ebiten.Key)
- func (k *Keyboard) TryAcceptKey(key ebiten.Key) bool
- func (k *Keyboard) TryToRegisterKeyPress(key ebiten.Key) bool
- func (k *Keyboard) TryToRegisterRepeatableKeyPress(key ebiten.Key) bool
- func (k *Keyboard) TryToRegisterRepeatableKeyPressWithRate(key ebiten.Key, rate RepeatRate) bool
- type ListNavigation
- func (n *ListNavigation) BlockUntilRelease(pressed func(ebiten.Key) bool)
- func (n *ListNavigation) Poll(k *Keyboard, keys ...ebiten.Key) (*ebiten.Key, bool)
- func (n *ListNavigation) PollWithKeyState(keyboard *Keyboard, pressed func(ebiten.Key) bool, keys ...ebiten.Key) (*ebiten.Key, bool)
- func (n *ListNavigation) Reset()
- type Modifier
- type RepeatRate
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Keyboard ¶
type Keyboard struct {
// contains filtered or unexported fields
}
func NewKeyboard ¶
func NewKeyboardWithKeyStateSource ¶
func NewKeyboardWithKeyStateSource( millisecondDelayBetweenKeyPresses int, keyPressed func(ebiten.Key) bool, ) *Keyboard
NewKeyboardWithKeyStateSource constructs a keyboard backed by a caller-owned key-state source. It supports deterministic input adapters and tests without changing the keyboard's release-debouncing behavior.
func (*Keyboard) ClearFrameConsumption ¶
func (k *Keyboard) ClearFrameConsumption()
ClearFrameConsumption cleans up released keys from consumption tracking Should be called once per frame by the main game loop at the START of Update() Only clears keys that are no longer physically pressed
func (*Keyboard) ForceLastKeyPressed ¶
func (*Keyboard) GetAlphaNumericPressed ¶
func (*Keyboard) GetArrowKeyAsDirection ¶
func (k *Keyboard) GetArrowKeyAsDirection() references.Direction
GetArrowKeyAsDirection returns the pressed arrow key as a Direction enum Returns references.NoneDirection if no arrow key is pressed Priority ordering: Down > Up > Right > Left
func (*Keyboard) GetBoundKeyPressed ¶
func (*Keyboard) GetMsSinceLastKeyPress ¶
func (*Keyboard) GetPressedArrowKey ¶
GetPressedArrowKey returns the currently pressed arrow key, or nil if none pressed Uses priority ordering to determine which key to return when multiple are pressed: Down (highest priority) > Up > Right > Left (lowest priority) This matches the priority used in original game movement logic
func (*Keyboard) GetPressedKey ¶
func (k *Keyboard) GetPressedKey() *semantic_input.Key
GetPressedKey returns the currently pressed key, prioritizing arrow keys Returns nil if no key is pressed Priority: Arrow keys (Down > Up > Right > Left) > Alpha (A-Z) > Numeric (0-9) > Control keys
Used by event queue WhileAwaitingInput() to detect which key stopped sailing Matches original Ultima V key detection priority for automatic sailing
Returns a framework-independent semantic key for use by core packages.
func (*Keyboard) IsAnyKeyPressed ¶
IsAnyKeyPressed checks if any key is currently pressed
func (*Keyboard) IsBoundKeyPressed ¶
func (*Keyboard) IsKeyHeld ¶
IsKeyHeld reads physical state through the same adapter used for modifiers and registered keys. It does not consume a key or bypass transition checks.
func (*Keyboard) IsKeyPressedAndRegister ¶
IsKeyPressedAndRegister is a convenience method combining key press detection with debouncing Returns true if the key is pressed AND the debounce time has elapsed Simplifies the common pattern: if IsKeyPressed && TryToRegisterKeyPress
func (*Keyboard) IsKeyPressedAndRegisterRepeatable ¶
IsKeyPressedAndRegisterRepeatable combines injected/simulated key detection with movement-style repeat registration.
func (*Keyboard) IsKeyPressedGetKey ¶
func (*Keyboard) IsModifierComboPressed ¶
IsModifierComboPressed checks if a modifier+key combination is currently pressed Returns true only if both the modifier and the specific key are pressed
func (*Keyboard) IsModifierPressed ¶
IsModifierPressed checks if a modifier key is currently pressed
func (*Keyboard) IsNumberKeyPressedAndRegister ¶
IsNumberKeyPressedAndRegister checks if any number key (0-9) is pressed. Returns the digit (0-9) if pressed and registered, or -1 if no number key is pressed. This simplifies the common pattern of checking all number keys in sequence.
func (*Keyboard) IsTextKeyPressedAndRegister ¶
IsTextKeyPressedAndRegister accepts each released-and-pressed text key without the movement repeat delay. Transition and held-key consumption still apply.
func (*Keyboard) IsWaitingForRelease ¶
IsWaitingForRelease returns true if keyboard is waiting for keys to be released Useful for UI feedback (e.g., showing "Release keys..." message)
func (*Keyboard) PrepareForTransition ¶
PrepareForTransition records currently pressed keys for release debouncing Use this when transitioning to a new UI state (e.g., dialog dismissal, KeyWait) to prevent key bleeding from the previous input
func (*Keyboard) ResetReleaseDebouncing ¶
func (k *Keyboard) ResetReleaseDebouncing()
ResetReleaseDebouncing clears all release debounce state Use when closing dialog or resetting UI
func (*Keyboard) SetAllowKeyPressImmediately ¶
func (k *Keyboard) SetAllowKeyPressImmediately()
func (*Keyboard) SetForceWaitAnyKey ¶
func (*Keyboard) SetLastKeyPressedNow ¶
func (k *Keyboard) SetLastKeyPressedNow()
func (*Keyboard) SetLastKeyPressedNowPlusMs ¶
func (*Keyboard) SimulateKeyPress ¶
SimulateKeyPress simulates a key press for testing purposes This bypasses the normal key press timing restrictions
func (*Keyboard) TryAcceptKey ¶
TryAcceptKey combines time-based and state-based release debouncing Returns true if the key should be processed, false if it should be ignored
This method implements two-phase checking: Phase 1 (State-based): If PrepareForTransition was called, wait for key release Phase 2 (Time-based): Standard repeat delay checking
func (*Keyboard) TryToRegisterKeyPress ¶
TryToRegisterKeyPress Tries to register a keypress. Returns true if keypress is allowed according to the time passed since the previous key press AND if the key hasn't been consumed already while held
func (*Keyboard) TryToRegisterRepeatableKeyPress ¶
TryToRegisterRepeatableKeyPress Tries to register a keypress that can repeat while held (e.g., movement keys). Returns true if keypress is allowed according to time-based debouncing and transition state. Unlike TryToRegisterKeyPress, this DOES NOT use release-based consumption, allowing continuous input while the key is held down. Use this for movement/navigation keys that should repeat when held.
func (*Keyboard) TryToRegisterRepeatableKeyPressWithRate ¶
func (k *Keyboard) TryToRegisterRepeatableKeyPressWithRate(key ebiten.Key, rate RepeatRate) bool
TryToRegisterRepeatableKeyPressWithRate is like TryToRegisterRepeatableKeyPress but uses a custom repeat rate instead of the default keyboard delay. Use RepeatRateSlow, RepeatRateMedium, or RepeatRateFast for common presets.
type ListNavigation ¶
type ListNavigation struct {
// contains filtered or unexported fields
}
ListNavigation resolves UI chords before consuming their physical keys. Its zero value is ready to use. Poll once per focused Update; Reset on focus loss or a change of input mode. Timing advances in update ticks, never wall time.
func (*ListNavigation) BlockUntilRelease ¶
func (n *ListNavigation) BlockUntilRelease(pressed func(ebiten.Key) bool)
BlockUntilRelease prevents a hold crossing a modal focus boundary.
func (*ListNavigation) Poll ¶
Poll returns a normalized navigation key when movement is due. owned remains true during throttled holds, so text input cannot consume/reset navigation. By default Up, Down, PageUp and PageDown are read. Explicit keys allow readers to include Home/End and menus to include Left/Right. Shift+Up/Down always maps to PageUp/PageDown; callers without paging deliberately ignore those intents.
func (*ListNavigation) PollWithKeyState ¶
func (n *ListNavigation) PollWithKeyState( keyboard *Keyboard, pressed func(ebiten.Key) bool, keys ...ebiten.Key, ) (*ebiten.Key, bool)
PollWithKeyState supports widgets whose existing physical-input adapter also owns their release gates. Production widgets normally use Poll.
func (*ListNavigation) Reset ¶
func (n *ListNavigation) Reset()
Reset discards a previous hold, for example when a nested modal takes focus.
type Modifier ¶
type Modifier int
Modifier represents keyboard modifiers (Ctrl, Shift, Alt, Meta/Command).
type RepeatRate ¶
type RepeatRate int
RepeatRate defines keyboard repeat speed presets in milliseconds
const ( RepeatRateSlow RepeatRate = 200 // Slow repeat rate (200ms between repeats) RepeatRateMedium RepeatRate = 120 // Medium repeat rate (120ms between repeats) RepeatRateFast RepeatRate = 120 // Legacy fast preset (120ms, same as Medium); UI lists use ListNavigation. )