KeyboardBehavior
Base for input behaviors that react to the software keyboard's lifecycle — appearing, hiding, animating, or changing frame — while the field is focused. Subclass to build a reaction: keep the field above the keyboard (KeyboardAvoidanceBehavior), dock a toolbar to the keyboard top, resize a scroll container, dim a backdrop, and so on. Desktop emits no keyboard events, so every subclass is inert there.
Remarks
Derived Types(1)
Types that inherit from KeyboardBehavior.
Whether the reaction is mid client-side animation and still needs OnKeyboardUpdate ticks — including an exit animation started in OnFocusLost that must finish after focus is already gone. The base keeps the per-frame tick alive while this holds, then releases it, so the field animates to rest rather than snapping.
The owning field gained focus. Capture any baseline state to restore on focus loss. If the keyboard is already up (switching fields under an open keyboard) a synthetic OnKeyboardWillChangeFrame follows immediately so the reaction can position itself.
The owning field lost focus. Restore any baseline state captured in OnFocusGained.
protected virtual void OnKeyboardWillShow(KeyboardEvent e)System is about to show the keyboard; e carries the destination rect plus animation duration/easing. Start any client-driven animation here.
protected virtual void OnKeyboardAnimationProgress(KeyboardEvent e)Per-frame system animation fraction, only on platforms reporting frame-synced animation (KeyboardEvent.hasFrameSyncedAnimation = Android API 30+). Elsewhere this never fires — animate from OnKeyboardUpdate instead.
protected virtual void OnKeyboardDidShow(KeyboardEvent e)The show animation finished and the keyboard is fully visible.
protected virtual void OnKeyboardWillHide(KeyboardEvent e)System is about to hide the keyboard. Start any client-driven hide animation here.
protected virtual void OnKeyboardDidHide(KeyboardEvent e)The hide animation finished and the keyboard is fully gone.
protected virtual void OnKeyboardWillChangeFrame(KeyboardEvent e)Keyboard frame changed without a hide/show cycle — iPad split-keyboard toggle, hardware keyboard connect/disconnect, rotation, language switch, or a field switch under an open keyboard.
Per-frame tick (unscaled delta) while focused, plus the tail of a client-side exit animation after focus loss (as long as IsAnimating holds). Drive client-side animation here on platforms without frame-synced progress (iOS, Android <30, WebGL).
