I don’t care about which key was pressed, or how long, or anything like that. All I need is a way to detect that the user has touched the screen, even if that happens to be on the part of the screen covered by a keyboard.
My goal here is to detect a lack of interaction to ‘reset’ the app to a default state if left along long enough — think a ‘kiosk mode’ application. The issue is that I can’t detect when the keyboard is touched, as the keyboard apparently intercepts all touch events, even before my customer window can handle them.
Edit:
Considered (and dismissed) is the use of just keyboard show and hide notifications — we need to prolong screen display if the user is actively typing. Since we use UIWebViews to display certain things, we also can’t use the delegate methods of UITextViews or UITextFields.
It sounds like detecting all touches—on the keyboard and elsewhere—would suffice. We can do that by subclassing
UIApplicationto overridesendEvent:.We’ll extend the
UIApplicationDelegateprotocol with a new message,application:willSendTouchEvent:, and we’ll make ourUIApplicationsubclass send the message to its delegate before handling any touch event.MyApplication.h
MyApplication.m
We’ll need to make our app delegate conform to the
MyApplicationDelegateprotocol:AppDelegate.h
AppDelegate.m
Finally, we need to make the app use our new
MyApplicationclass:main.m