简体   繁体   中英

How to detect iOS keyboard 'next' key with javascript

So I have a small SPA written in JS. It has several input fields, but no actual 'form'. Everything is bound with JS.

When the user gets to the last input on a form page, if they press 'tab' or 'enter', I hijack the key event and fire the animation to scroll the next form page in. This all works great.

However, when a user visits on iOS (or android for that matter) if they start filling out inputs and hit the 'next' key, when they reach the end of a form section, the device focuses the next input off screen, and breaks the entire layout, scrolling the viewport in awkward ways and such.

So my question is

1) Is there a way through JS to hijack the 'next' button and properly fire my animations?

or

2) Is there a way to hide the prev/next buttons?

or

3) Is there a way to prevent the 'next' button from jumping to the next section?

I tried making a small jsfiddle that fired an alert on keyup, but the 'next' key doesn't seem to have any sort of keycode, or even to fire the keyup event :/

Thank you for any help.

我会尝试在每页的最后一个真实字段之后添加隐藏的虚拟输入字段,并在获得焦点时随时转到下一页。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM