Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Keyboard input WebGL Mobile

Discussion in 'Web' started by tmorelli, Nov 19, 2017.

  1. tmorelli

    tmorelli

    Joined:
    Apr 22, 2015
    Posts:
    2
    I have an InputField that works on most browsers, however on mobile the virtual keyboard does not pop up. everything else is working good on mobile for me except for that. I am wondering if anyone has gotten it to work. All i have found are posts about it not working. If this just doesnt work, I think my options are using my own virtual keyboard, or somehow sending form data to the webGL unity app. Has anyone encountered this? What did you do?

    Thanks
     
    AliveDrive, Talmagett, Novack and 2 others like this.
  2. RafaelEffects

    RafaelEffects

    Joined:
    Mar 3, 2018
    Posts:
    1
    Did you solved it? I`m facing the same issue...
     
  3. zephybite0

    zephybite0

    Joined:
    Apr 25, 2018
    Posts:
    30
  4. Uli_Okm

    Uli_Okm

    Joined:
    Jul 10, 2012
    Posts:
    95
    ProGameDevUser likes this.
  5. MrEdens

    MrEdens

    Joined:
    Sep 1, 2016
    Posts:
    2
    I tried adding this work around but only end up getting multiple errors. Unity 2018.3.4
     
  6. maira_iida

    maira_iida

    Joined:
    Dec 10, 2018
    Posts:
    1
    I also tried this. It opens my mobile keyboard, but when I start typing, nothing changes. Unity 18.2.12
     
  7. Prince_of_Persia

    Prince_of_Persia

    Joined:
    Oct 20, 2012
    Posts:
    57
  8. OscarJasso01

    OscarJasso01

    Joined:
    Apr 5, 2017
    Posts:
    1
    Thanks for this contribution. I implemented it in my own game and it does the job indeed, however, I found the following issues:

    1) If you use the first option (native), there is a not-so-friendly pop up with information about the server/site, prompting to the text input via mobile keyboard. After submitting the text, the game exits full-screen mode (if so).
    2) the second options (browser prompt) seems to prevent the issue described above, however, it depends on the resolution of both the game and the mobile browser. Perhaps there is a way to configure it in order to display it properly in case you having different resolutions? (e.g. your WebGL game is full-screen).

    BTW I uploaded a sample game to itch.io using this asset. I haven't tried via GitHub or any other server.
     
  9. nbkhanhdhgd

    nbkhanhdhgd

    Joined:
    Apr 19, 2016
    Posts:
    23
    Thank you for your sample project.
    It have problem: Input Field Native changed event On Value Change instead of Input Field default (On Value Change (string)). Can you help me how can I implement Input Field default event On Value Change (string)?
     
  10. StarArcher

    StarArcher

    Joined:
    May 23, 2020
    Posts:
    12
    Update Jan 20, 2021: v2020.2.1f1 -- problem still exists.
     
  11. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    953
    Adding support for bringing up the virtual keyboard is currently on our radar. We are hoping to land that in to 2021.2 (and possibly backport if code structure permits).
     
  12. PyrateAkananto

    PyrateAkananto

    Joined:
    May 8, 2018
    Posts:
    12
  13. Nyanpas

    Nyanpas

    Joined:
    Dec 29, 2016
    Posts:
    406
    I have tried all of these thirdparties now and none of them work...

    No idea if it is because of the implementation or the version of Unity. I am on 2020.2.0f1.
     
    mimiCryMuffin and Granchachan like this.
  14. Granchachan

    Granchachan

    Joined:
    Jan 28, 2021
    Posts:
    1
    Im trying customers to login into a game made in WebGL and it's frustrating that nothing happens. I'm feeling frustrated. It´s just a stupid thing and it doesn't work. Is there a simply way to do it? I'm searching the whole web and nothing helps.
     
  15. Hypertectonic

    Hypertectonic

    Joined:
    Dec 16, 2016
    Posts:
    75
    It's annoying that this feature is missing.
    Solution: make your own keyboard inside Unity with GUI buttons. It's a drag, but it works.
     
  16. brendanduncan_u3d

    brendanduncan_u3d

    Unity Technologies

    Joined:
    Jul 30, 2019
    Posts:
    480
    Mobile keyboard input is on our task list. We know this is a significant missing feature for mobile support.
     
    brianduper, Blarp and Nyanpas like this.
  17. Eorlinger

    Eorlinger

    Joined:
    Aug 14, 2015
    Posts:
    1
    Do you guys have any time frame when this feature will be available?
    I have a project for a customer which first was made for native mobile. But because of well considered reasons, we decided to switch to WebGL. Everything is working except for a stupid contact page.
    Now 1 week before the deadline, I have to tell the customer it is not possible with Unity. Not even a workaround. I tried all the available "workarounds", but none of them are working on all the platforms.

    UPDATE:
    I'm willing to use a beta version for it as well. Or some advice that I can use to make it work.
     
    Last edited: Jun 21, 2021
    Nyanpas likes this.
  18. Nyanpas

    Nyanpas

    Joined:
    Dec 29, 2016
    Posts:
    406
    One solution I am considering is just making a separate HTML-based (with JS)-interface that communicates with an "API" provided by the Web Assembly that just accepts strings, so it can work as a text-based interface without having to use Unity's own GUI. However, I am still in the exploration phase and I wonder how, or even if, this is feasible.
     
    Eorlinger likes this.
  19. Juang3d

    Juang3d

    Joined:
    Sep 25, 2012
    Posts:
    87
    @brendanduncan_u3d this has been a detected problem since more than 2018.

    Can you tell us a time frame to have this solved already?

    It's ridiculous that things like this are still a problem in a rental software, supposedly the change to rental only should provide a much bigger and better support, like fixing old problems like this one.

    @Eorlinger this is ridiculous, but if you manage to solve this, please tell us your solution
     
    Nyanpas likes this.
  20. brendanduncan_u3d

    brendanduncan_u3d

    Unity Technologies

    Joined:
    Jul 30, 2019
    Posts:
    480
    We cannot give you a time frame, but it is part of our mobile support plan that has been in progress. I understand it is frustrating not having a built-in mobile keyboard solution.
     
  21. sama-van

    sama-van

    Joined:
    Jun 2, 2009
    Posts:
    1,737
  22. Nyanpas

    Nyanpas

    Joined:
    Dec 29, 2016
    Posts:
    406
    Quoting myself like a narcy.

    Anyhow, the JS-created plugin-library that communicates with a standalone HTML5/JS-frontend which communicates with Unity seems to work. It is just "slightly" more effort.
     
    sama-van likes this.
  23. greatergoodguy

    greatergoodguy

    Joined:
    Jan 10, 2013
    Posts:
    7
    I really want this feature as well. Keyboard on WebGL mobile would be a game changer.

    @brendanduncan_u3d Any updates?
     
  24. sama-van

    sama-van

    Joined:
    Jun 2, 2009
    Posts:
    1,737
    I did a very lot of test recently using JS.

    What I was thinking is that creating on request a temp input to the html page and then force .click() and .focus() to it would actually open the keyboard but it doesn't.

    I even made a sort domino event of creating a button to the html page, which I also force the .click() to make a input field where I then force again the .focus() and .click().
    Somehow it works on android but Safari iOS doesn't care at all.

    If you search more on very Javascript community wondering how to pop that keyboard, it's basically impossible from Javascript it seems :
    - https://github.com/jquery/jquery-mo...1a1Jl9EJ69oFOT5Q2q1743t6uH5BpTeJdx2yhhLG-7-xI

    There is also a very tiny sample on jsfiddle you can give a try on your different device :
    - http://jsfiddle.net/kzUuG/1/
    Basically the target is to force the .focus() and .click() to get that keyboard poping but nothing doe on iOS.

    I mean at that level, it needs a very deep JavaScript or other web language oriented to find a solution to it...


    Then the final option which is just really, and truly the final and super simple one is to use a Prompt.

    Basically parse every input object on your UI and assign a script to Javascript to call that prompt(title, text);
    Something like that :

    Code (csharp):
    1.  
    2.  
    3. function MobileKeyboardShowJS(objSource, text, subText, msgOnEdit) {
    4.     var result = prompt(subText, text);
    5.  
    6.     if (result == null || result == "") {
    7.     } else {
    8.         unityInstance.SendMessage(objSource, msgOnEdit, result);
    9.     }
    10.  
    It's awful I know... but for the remaining time...
     
  25. brendanduncan_u3d

    brendanduncan_u3d

    Unity Technologies

    Joined:
    Jul 30, 2019
    Posts:
    480
    @greatergoodguy I have a PR for the mobile keyboard support currently in review. One thing to note, though, is it will have to be for Unity 2022, since I won't be able to backport new features.
     
    sama-van and Hypertectonic like this.
  26. brendanduncan_u3d

    brendanduncan_u3d

    Unity Technologies

    Joined:
    Jul 30, 2019
    Posts:
    480
    @sama-van The keyboard can only be invoked by focusing an input, either directly or procedurally, within a user action event such as touchdown/up or mousedown/up.
     
    shacharoz likes this.
  27. Hypertectonic

    Hypertectonic

    Joined:
    Dec 16, 2016
    Posts:
    75
    Unity 2022??? or Unity 2021.2??
     
  28. brendanduncan_u3d

    brendanduncan_u3d

    Unity Technologies

    Joined:
    Jul 30, 2019
    Posts:
    480
    Unfortunately 2021.2 has been feature locked as we focus on fixing the issues that resulted from all the changes that were made to that version. Being a new feature, the mobile keyboard work will end up in the 2022 cycle.
     
    shacharoz likes this.
  29. sama-van

    sama-van

    Joined:
    Jun 2, 2009
    Posts:
    1,737
    hmmm... then yeah definitely can't fake those events by script...
     
  30. brendanduncan_u3d

    brendanduncan_u3d

    Unity Technologies

    Joined:
    Jul 30, 2019
    Posts:
    480
    sama-van likes this.
  31. Hypertectonic

    Hypertectonic

    Joined:
    Dec 16, 2016
    Posts:
    75
    Unfortunate indeed, that's a lot of time to wait, but thanks for your work on this.
     
  32. kou-yeung

    kou-yeung

    Joined:
    Sep 5, 2016
    Posts:
    32
    i don't sure it is same issue...
    if call html function from Unity.
    some api have browser's security mechanisms for this.

    you can try to register your custom function at mouse down event.
    and exec this at mouse up event.
    FYR : https://github.com/valyard/UnityWebGLOpenLink
     
    Last edited: Sep 3, 2021
  33. atmosquare_

    atmosquare_

    Joined:
    Mar 15, 2021
    Posts:
    1
  34. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,999
  35. CodeStarrk

    CodeStarrk

    Joined:
    Jan 5, 2017
    Posts:
    37
    Will this already be in Alpha? Or will it be beta or later?
     
  36. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,999
    This is broken in Unity 2021.2 Beta 11

    So my question is, 'd we get official support in 2022.1 for copy paste?
     
  37. brendanduncan_u3d

    brendanduncan_u3d

    Unity Technologies

    Joined:
    Jul 30, 2019
    Posts:
    480
    Copy/paste will work in the one I just developed for 2022.
     
    jGate99 and KamilCSPS like this.
  38. brendanduncan_u3d

    brendanduncan_u3d

    Unity Technologies

    Joined:
    Jul 30, 2019
    Posts:
    480
    @davoMayn It's not in alpha yet, it's still being testing/reviewed.
     
    KamilCSPS likes this.
  39. CodeStarrk

    CodeStarrk

    Joined:
    Jan 5, 2017
    Posts:
    37
    Alright gotcha, can't wait :)
     
  40. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,999
    awesome, hopefully in 2022.1 beta
     
  41. brendanduncan_u3d

    brendanduncan_u3d

    Unity Technologies

    Joined:
    Jul 30, 2019
    Posts:
    480
    iOS15 Safari caused a few last minute issues I had to get sorted out. Fixing up the final bits now and it will get out shortly after that, the merge process always being variable amount of time.
     
    harrymanjan14 and De-Panther like this.
  42. harrymanjan14

    harrymanjan14

    Joined:
    Sep 6, 2015
    Posts:
    6
    looking forward to this.
     
  43. kou-yeung

    kou-yeung

    Joined:
    Sep 5, 2016
    Posts:
    32
  44. CodeStarrk

    CodeStarrk

    Joined:
    Jan 5, 2017
    Posts:
    37
    Hi! Do you have more info on this now? As in around which date can we expect the 2022 beta? Or will this feature be in late alpha?
     
  45. brendanduncan_u3d

    brendanduncan_u3d

    Unity Technologies

    Joined:
    Jul 30, 2019
    Posts:
    480
    I'm pushing on people to finalize the review. Where it lands is out of my control, I wish I could give you a more definitive answer.
     
    AliveDrive likes this.
  46. CodeStarrk

    CodeStarrk

    Joined:
    Jan 5, 2017
    Posts:
    37
    Thank you
     
  47. brendanduncan_u3d

    brendanduncan_u3d

    Unity Technologies

    Joined:
    Jul 30, 2019
    Posts:
    480
    The keyboard code has landed in the main branch, so I it will be in the public build soon.
     
  48. CodeStarrk

    CodeStarrk

    Joined:
    Jan 5, 2017
    Posts:
    37
    SWEET! I assume this will be 2022.1.0 Alpha 12 then?
     
  49. greatergoodguy

    greatergoodguy

    Joined:
    Jan 10, 2013
    Posts:
    7
    This is awesome!! I appreciate your work so much!! I've been working on an online game that's playable in the web browser, and my testers are frustrated that they are unable to change their display name. I'm so excited, this is going to be amazing.
     
    brendanduncan_u3d likes this.
  50. KamilCSPS

    KamilCSPS

    Joined:
    May 21, 2020
    Posts:
    455
    Release notes say it's in a13. Haven't tested it.
     
    EKardelis likes this.