我正在尝试使用react-native构建条形码扫描仪应用程序。
我正在尝试使用react-native-keyevent,但到目前为止,还没有运气。在我的组件代码下方。
import React from 'react';
import KeyEvent from 'react-native-keyevent';
export default class ScannerKey extends React.Component {
render() {
return null;
}
componentDidMount() {
console.log('ScannerKey MOUNTED');
KeyEvent.onKeyDownListener((keyEvent) => {
console.log(keyEvent);
});
// KeyEvent.onKeyUpListener((keyEvent) => {
// console.log(keyEvent);
// });
// KeyEvent.onKeyMultipleListener((keyEvent) => {
// console.log(keyEvent);
// });
}
}