Jump to content

textbox on canvas, how to show virtual keyboard on IPad/android?


Rnd-
 Share

Recommended Posts

On iOS, you would have to add an actual textbox (an <input> element) to the DOM, and place it behind your canvas, which you can do by setting its z-index via css. When the user clicks your canvas textbox, you call focus() on the DOM textbox, which makes the virtual keyboard appear.

 

There are some caveats though, if I remember correctly the DOM textbox must also have a "position: fixed" css attribute to avoid Safari moving your canvas around, and possibly something else (I did this a while ago, can't remember exactly).

 

Android doesn't mean much... the above method would work in Chrome for Android, and potentially Firefox too, but there are problems with other browsers (Dolphin is a problematic one, iirc). Also other operating systems such as windows phone and firefox OS won't be happy with that method. You would have to detect the useragent, and do something different depending on the browser... I think I ended up using a javascript prompt() on anything that wasn't iOS or Chrome for Android. It was used in this game here (to try it select multiplayer mode and don't log in via facebook).

Link to comment
Share on other sites

  • 3 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...