Detect virtual keyboard vs. hardware keyboard

前端 未结 6 2083
心在旅途
心在旅途 2020-12-05 06:36

I have been thinking about this a while now, and I can\'t figure a way to deal with it. Is there any way to detect if the user uses a virtual (software) keyboard or a tradit

6条回答
  •  攒了一身酷
    2020-12-05 07:28

    I don't think overriding default onscreen keyboard is a good idea, and I'd recommend going with what Jani suggested - virtual keyboards adapt too.

    But I'm sure it is possible to detect most keyboards with the resize event paired with focus on the field or by monitoring window.innerHeight (or some other [a-z]*Height) and comparing value before and after field focus.

    This is a weird case of feature detection, so it will need plenty of experimentation. I wouldn't do it if I were you.

提交回复
热议问题