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.
- Function Component
- Class Component
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:
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
This can be any of the following:
keyboardWillShow
keyboardDidShow
keyboardWillHide
keyboardDidHide
keyboardWillChangeFrame
keyboardDidChangeFrame
Note that if you set
android:windowSoftInputMode
toadjustResize
oradjustPan
, onlykeyboardDidShow
andkeyboardDidHide
events will be available on Android. If you setandroid:windowSoftInputMode
toadjustNothing
, no events will be available on Android.keyboardWillShow
as well askeyboardWillHide
are generally not available on Android since there is no native corresponding event.
removeListener()
β
static removeListener(eventName, callback)
Deprecated. Use the
remove()
method on the event subscription returned byaddListener()
.
Parameters:
Name | Type | Required | Description |
---|---|---|---|
eventName | string | Yes | The nativeEvent is the string that identifies the event you're listening for |
callback | function | Yes | The function to be called when the event fires |
removeAllListeners()
β
static removeAllListeners(eventName)
Removes all listeners for a specific event type.
Parameters:
Name | Type | Required | Description |
---|---|---|---|
eventType | string | Yes | The 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.