React Native Expo - How to get Zebra Scanner pressed keyboard value without text input

317 Views Asked by At

I'm trying to develop React Native Expo app on Zebra Scanner OS android. I want to listen pressed F Keys or any physical keyboard events on main screen without text input. So far I tried couple of npm package but they didn't solve my problem. And keyboard expo doc only works for 'keyboardDidShow' and 'keyboardDidHide' Does anyone know how to handle keyevents on React Native Expo ?

https://github.com/chronsyn/react-native-keyevent-expo-config-plugin

This code didn't work.

import KeyEvent from 'react-native-keyevent';
  useEffect(() => {
    KeyEvent.onKeyDownListener((keyEvent) => {
      console.log(`onKeyDown keyCode: ${keyEvent.keyCode}`);
      console.log(`Action: ${keyEvent.action}`);
      console.log(`Key: ${keyEvent.pressedKey}`);
    });

    KeyEvent.onKeyMultipleListener((keyEvent) => {
      console.log(`onKeyDown keyCode: ${keyEvent.keyCode}`);
      console.log(`Action: ${keyEvent.action}`);
      console.log(`Key: ${keyEvent.pressedKey}`);
    });
  });
0

There are 0 best solutions below