How to detect keyboard enter key?

前端 未结 4 659
广开言路
广开言路 2021-01-16 13:50

I have on UIWebView in that i am allowing editing at runtime.

Now when i click on UIWebView then iPad keyboard opens for writing, now my re

4条回答
  •  情话喂你
    2021-01-16 14:14

    I don't think there is a public API for dealing with the keyboard at that level. It's quite a big effort (because of international keyboards) but one option would be to listen to UIKeyboardWillShow notifications and overlay the keyboard with transparent UIViews for the buttons you want to listen to. You could capture the touch, then pass it on to the views below (the keyboard) and let it do its thing.

    You could even override (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event; in your transparent button. So you capture the fact that it's been touch but return NO anyway so that the keyboard gets the touch.

    The difficulty is then to know where each key is, depending on the keyboard types you need to support.

提交回复
热议问题