3

I am developing this site that takes a keyboard input and processes it as it is being typed with no use of forms or inputs, I am calling a function with a keypress event.

I tried to test in my mobile device and oh, surprise! the keyboard doesn't show if there's no input field!

How can I force the keyboard to show up with Javascript if there are no input fields?

Thank you!

guergana
  • 374
  • 5
  • 19
  • 1
    What about hidden inputs? – putvande Jul 09 '16 at 22:13
  • I thought about it, but.. is there a way to do it without using hidden inputs? – guergana Jul 09 '16 at 22:14
  • What's wrong with hidden inputs? Focus the input and you can capture events just like that. It's not really any different from listening for key events on the document - it's just that the document is always focused. – Jack Guy Jul 09 '16 at 22:16
  • have you considered that maybe that's not very user-friendly for a mobile version. Maybe you should consider capturing the input some other way on mobile. – ADyson Jul 09 '16 at 22:17
  • It's an experimental website... using inputs just doesn't fit in the design. But hidden inputs could be a solution. – guergana Jul 09 '16 at 22:18

1 Answers1

0

Maybe this answer is of help to you: Manually triggering the iPhone/iPad/iPod keyboard from JavaScript

Since you're mentioning calling a function with a keypress event

<input type='text' id='foo'><div onclick='$("#foo").focus();'>click</div>
Community
  • 1
  • 1
Daniel
  • 10,641
  • 12
  • 47
  • 85