Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
3
Question by dark_end · Jun 24, 2015 at 08:01 PM · inputcanvaswebglkeyboard inputhtml5

WebGL - Module.doNotCaptureKeyboard: true or Module.keyboardListeningElement: ... NOT WORKING ANYMORE

Since the Update to the latest Unity 5 Editor version these two options do not work anymore (Module.keyboardListeningElement, Module.doNotCaptureKeyboard) .

The WebGL Canvas is always eating all the keyboard input, no matter if these options are set or not.

Built with Unity 5.0.1 before and those options worked and I was able to use Input fields, etc. in the DOM.

Built with Unity 5.1.1 now and this option isnt working anymore.

Is there any change I have missed?

Thanks for the help.

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image RSoj · Jun 25, 2015 at 08:51 AM 0
Share

Just spent 5 hours to investigate the same hair-pulling issue. Waiting for response with you.

1 Reply

· Add your reply
  • Sort: 
avatar image
5
Best Answer

Answer by RSoj · Jun 25, 2015 at 12:41 PM

I have created a workaround. Still waiting for "the right way" answer though.

1) Add html input field to your page (or use the one which worked for you with Unity 5.0.1), e.g.:

 <input id="WebGLKeyboardInput" type="text" name="WebGLKeyboardInput" value="" />

2) Add following javascript function to your page

 hackWebGLKeyboard: function ()
 {
     var webGLInput = document.getElementById('WebGLKeyboardInput');
     for (var i in JSEvents.eventHandlers)
     {
         var event = JSEvents.eventHandlers[i];
         if (event.eventTypeString == 'keydown' || event.eventTypeString == 'keypress' || event.eventTypeString == 'keyup')
         {
             webGLInput.addEventListener(event.eventTypeString, event.eventListenerFunc, event.useCapture);
             window.removeEventListener(event.eventTypeString, event.eventListenerFunc, event.useCapture);
         }
     }
 }

3) Call the hackWebGLKeyboard() function after WebGL has been initialized (I'm calling it from Start method on MonoBehaviour in scene)

4) Any time you need to switch input to your game, call following javascript as before

 document.getElementByID('WebGLKeyboardInput').focus()


Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image dark_end · Jun 25, 2015 at 01:33 PM 0
Share

Thank you a lot for the workaround.

Also waiting for a proper fix, in the Unity Issue Tracker I found the same Issue with status "Fixed in Future Release", but it was already a month old (V. 5.1.0) and there were some editor updates since then: http://issuetracker.unity3d.com/issues/donotcapturekeyboard-not-working-in-webgl

So I created a new Bug Report in the hopes it gets noticed.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Keyboard and Controller Input Not Working in WebGL 1 Answer

How to integrate HTML5 elements in Unity ? 2 Answers

New input system doesn't work on webgl build for android 0 Answers

in webgl , how to change #canvas property? 0 Answers

Need to send Secondary camera render from unity webgl to HTML5 canvas 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges