Closed RomainRicord closed 2 years ago
I try with this code
import React,{useEffect} from 'react' import {View} from 'react-native' import KeyEvent from 'react-native-keyevent' const App = () => { useEffect(() => { KeyEvent.onKeyDownListener((keyEvent) => { console.log(`onKeyDown keyCode: ${keyEvent.keyCode}`); console.log(`Action: ${keyEvent.action}`); console.log(`Key: ${keyEvent.pressedKey}`); }); // if you want to react to keyUp KeyEvent.onKeyUpListener((keyEvent) => { console.log(`onKeyUp keyCode: ${keyEvent.keyCode}`); console.log(`Action: ${keyEvent.action}`); console.log(`Key: ${keyEvent.pressedKey}`); }); // if you want to react to keyMultiple KeyEvent.onKeyMultipleListener((keyEvent) => { console.log(`onKeyMultiple keyCode: ${keyEvent.keyCode}`); console.log(`Action: ${keyEvent.action}`); console.log(`Characters: ${keyEvent.characters}`); }); return () => { KeyEvent.removeKeyDownListener(); KeyEvent.removeKeyUpListener(); KeyEvent.removeKeyMultipleListener(); } }, []) return( <View style={{flex:1,backgroundColor:'white'}}> </View> ) } export default App
No console.log when I press volume button
Dependencies: "dependencies": { "react": "18.0.0", "react-native": "0.69.1", "react-native-keyevent": "^0.2.8", "react-native-system-setting": "^1.7.6" },
I miss configure MainActivity
I try with this code
No console.log when I press volume button
Dependencies: "dependencies": { "react": "18.0.0", "react-native": "0.69.1", "react-native-keyevent": "^0.2.8", "react-native-system-setting": "^1.7.6" },