Skip to main content

Keyboard

Keyboard module to control keyboard events.

Usage​

The Keyboard module allows you to listen for native events and react to them, as well as make changes to the keyboard, like dismissing it.


Reference

Methods​

addListener()​

static addListener(eventName, callback)

The addListener function connects a JavaScript function to an identified native keyboard notification event.

This function then returns the reference to the listener.

Parameters:

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

This can be any of the following:

  • keyboardWillShow
  • keyboardDidShow
  • keyboardWillHide
  • keyboardDidHide
  • keyboardWillChangeFrame
  • keyboardDidChangeFrame

Note that only keyboardDidShow and keyboardDidHide events are available on Android. The events will not be fired when using Android 10 and under if your activity has android:windowSoftInputMode set to adjustNothing.


removeListener()​

static removeListener(eventName, callback)

Deprecated. Use the remove() method on the event subscription returned by addListener().

Parameters:

NameTypeRequiredDescription
eventNamestringYesThe nativeEvent is the string that identifies the event you're listening for
callbackfunctionYesThe function to be called when the event fires

removeAllListeners()​

static removeAllListeners(eventName)

Removes all listeners for a specific event type.

Parameters:

NameTypeRequiredDescription
eventTypestringYesThe native event string listeners are watching which will be removed

dismiss()​

static dismiss()

Dismisses the active keyboard and removes focus.


scheduleLayoutAnimation​

static scheduleLayoutAnimation(event)

Useful for syncing TextInput (or other keyboard accessory view) size of position changes with keyboard movements.