Saltar al contenido principal
Versión: 0.82

Teclado

Traducción Beta No Oficial

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()

tsx
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:

NameTypeDescription
eventName
Required
stringThe string that identifies the event you're listening for. See the list below.
callback
Required
functionThe function to be called when the event fires

eventName

Puede ser cualquiera de los siguientes:

  • keyboardWillShow

  • keyboardDidShow

  • keyboardWillHide

  • keyboardDidHide

  • keyboardWillChangeFrame

  • keyboardDidChangeFrame

nota

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()

tsx
static dismiss();

Oculta el teclado activo y quita el foco.


scheduleLayoutAnimation

tsx
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()

tsx
static isVisible(): boolean;

Indica si se sabe que el teclado estaba visible la última vez.


metrics()

tsx
static metrics(): KeyboardMetrics | undefined;

Devuelve las métricas del teclado virtual si está visible.