Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Keyboard not working in WebGL if loaded in background

Discussion in 'WebGL' started by Gaspar, Jun 12, 2015.

  1. Gaspar

    Gaspar

    Joined:
    Jun 14, 2014
    Posts:
    28
    Keyboard not working for me in WebGL builds if project loaded in background.

    Project to test:
    http://gasparfx.itch.io/webglkayboardbug?secret=x3vJHMCQencwS1JJeST7y3BIUi4

    Code(I know its not good to add force in regular Update, but want to keep it simple):
    Code (CSharp):
    1. void Update () {
    2.     if (Input.GetButtonDown("Fire1"))
    3.     {
    4.         cube.AddForce(Vector3.up * 5, ForceMode.Impulse);
    5.     }
    6. }
    1. Open/Refresh page and minimize browser or change focus to some other application.
    2. Wait till application loaded
    3. Play game. I can push cube with mouse clicks, but not with Ctrl key.
    4. If make game fullscreen Ctrl key works again.

    Tested with Firefox and Chrome
     
  2. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    Confirmed. I'm filing myself a bug for this. Might get back for more info if needed.
     
    Gaspar likes this.
  3. Gaspar

    Gaspar

    Joined:
    Jun 14, 2014
    Posts:
    28
    I already did it, btw. Case 704225
    But may be someone have a workaround for this? Some html editting f.e.
     
  4. Gaspar

    Gaspar

    Joined:
    Jun 14, 2014
    Posts:
    28
    I think i found a better way to reproduce this.

    http://prntscr.com/7hliur
    After click on Zone 1 - Keyboard doesnt work in game
    After click on Zone 2 - Keyboard works in game

    Now in seems like an issue with html hierarchy on itch.io website.

    But problem remains - focus is still lost after i click in game window with mouse. Its very unclear for users that they must click on empty space near the game.

    May be now someone can suggest something to solve this?
     
  5. meta_monkey

    meta_monkey

    Joined:
    Feb 22, 2018
    Posts:
    6
  6. JamesArndt

    JamesArndt

    Unity Technologies

    Joined:
    Dec 1, 2009
    Posts:
    2,913
  7. Schubkraft

    Schubkraft

    Unity Technologies

    Joined:
    Dec 3, 2012
    Posts:
    1,067
    This was fixed in 5.2 and I just checked it in 2019.2 and it still looks fixed.

    If it isn't for you, please submit a new bug report with a repro project and ping the case ID here.