In my Xamarin.iOS app (C#), I have a iPhoneOSGameView
(which inherits from UIView
), and I would like to capture key presses from an external (say bluetooth) keyboard.
Since this is to add support for keyboard control in a game, I want to be able to respond to these events without having to place a textbox or any other text field as proposed in this question (actually, they're not capturing key presses, but textbox changes, which is completely different from what I want to do)
In Android, I can achieve this by overriding OnKeyDown
and OnKeyUp
in my activity, but there seem to be no similar events either on UIView
or UIViewController
.
Is there a way to capture key presses and key releases in either UIView
or UIViewController
?
Since this is for Xamarin.iOS, I would certainly prefer a C# answer, but I guess I can read Objective-C if needed.