My need is to hook events from HID scanner ( which works same as physical keyboard ) to read barcode in Xamarin forms on Master-detail app. I dont have any input field on my page. I found that it works well on Android and UWP but does not work on iOS.
Let me explain you step wise only for iOS since it is not working. (Android and UWP does not have issues listening to keypress)
- I have Master detail app. My need is to receive key press events on Detail pages.
- I dont have any input field on my page. I can't have entry input field bcoz that is my requirement.
- Hence decided to listen key events at detail page level
- To hook key events, I have added key commands using AddKeyCommand(..) in detail page renderer in iOS
Taken from this link : Is it possible to hook into Hardware keyboard events at an Application level?
- I have created Master-Detail app using wizard provided in VS 2017 for Xamarin forms and added above code in About page renderer. But its not working. "KeyRecv" handler is not hitting on keys from HID scanner
- I have tried same code with normal single page sample. Again I have used VS2017 wizard to create this sample. Now in this I have created page renderer for MainPage. To my surprise, it has work in single page sample.
- So question is why not working in Master-Detail page.
- Additional point. I am not setting Focus anywhere in application neither for Master-detail nor for Single page app.
- OnElementChanged gets called during debugging for respective page.
- These are pure wizard created apps with above code.
So what is the issue with master-detail page app in Xamarin forms on iOS? (Remember these works well with Android and UWP)