Teclado
Esta página fue traducida por PageTurner AI (beta). No está respaldada oficialmente por el proyecto. ¿Encontraste un error? Reportar problema →
Módulo Keyboard para controlar eventos del teclado.
Uso
El módulo Keyboard te permite escuchar eventos nativos y reaccionar ante ellos, además de realizar cambios en el teclado, como ocultarlo.
Referencia
Métodos
addListener()
static addListener: (
eventType: KeyboardEventName,
listener: KeyboardEventListener,
) => EmitterSubscription;
La función addListener conecta una función de JavaScript a un evento de notificación nativo del teclado identificado.
Esta función devuelve entonces la referencia al listener.
Parámetros:
| Name | Type | Description |
|---|---|---|
| eventName Required | string | The string that identifies the event you're listening for. See the list below. |
| callback Required | function | The function to be called when the event fires |
eventName
Puede ser cualquiera de los siguientes:
-
keyboardWillShow -
keyboardDidShow -
keyboardWillHide -
keyboardDidHide -
keyboardWillChangeFrame -
keyboardDidChangeFrame
Solo los eventos keyboardDidShow y keyboardDidHide están disponibles en Android. Los eventos no se activarán si usas Android 10 o inferior y tu actividad tiene android:windowSoftInputMode configurado como adjustResize o adjustNothing.
dismiss()
static dismiss();
Oculta el teclado activo y quita el foco.
scheduleLayoutAnimation
static scheduleLayoutAnimation(event: KeyboardEvent);
Útil para sincronizar cambios de tamaño o posición en TextInput (u otras vistas accesorias del teclado) con los movimientos del teclado.
isVisible()
static isVisible(): boolean;
Indica si se sabe que el teclado estaba visible la última vez.
metrics()
static metrics(): KeyboardMetrics | undefined;
Devuelve las métricas del teclado virtual si está visible.