1.0.7 • Published 4 years ago

keycode-for-android v1.0.7

Weekly downloads
83
License
Apache-2.0
Repository
github
Last release
4 years ago

keycode-for-android

Return keycode for android. Could be useful for appium android test.

Data from Android KeyEvent.

As you know, Android keycodes are different from PCs. For example, "Enter" keycode is 13 on PC but 66 on Android. This module gives your the Android's.

Usage

Install 'keycode-for-android' into your project:

npm i -S keycode-for-android

require and use it!

const keycode = require('keycode-for-android')

// You can use a keycode name which is exactly the same as Google document.
keycode('KEYCODE_ENTER') // Return 66

// You can use a short name, with out "KEYCODE_"
keycode('ENTER') // Return 66

// Lowercase is OK, too.
keycode('Enter') // Return 66
keycode('enter') // Return 66

// From keycode to its name.
keycode(66) // Return 'KEYCODE_ENTER'
keycode('66') // Return 'KEYCODE_ENTER'

// Return undefined if a keycode name is unknown or a keycode isn't exist.
keycode('AN_UNDEFINED_KEYCODE_NAME') // Return undefined
keycode(1234) // Return undefined

Fork me on github.

1.0.7

4 years ago

1.0.6

4 years ago

1.0.2

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago