Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question GetKeyDown(KeyCode.Space) Macos dont work

Discussion in 'Getting Started' started by bratka_panya, Oct 12, 2021.

  1. bratka_panya

    bratka_panya

    Joined:
    Aug 9, 2021
    Posts:
    3
    GetKeyDown(KeyCode.Space) or GetKeyDown("space") dont work on Macos (bluetooth keyboard)

    Please help!
    Code (CSharp):
    1. void Update()
    2.     {
    3.         if (Input.GetKeyDown("space") && isOnGround)
    4.         {
    5.             Debug.Log("Space pressed");
    6.             playerRb.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);
    7.             isOnGround = false;
    8.         }
    9.     }
     
  2. bratka_panya

    bratka_panya

    Joined:
    Aug 9, 2021
    Posts:
    3
    Project correctly working on Windows, but dont work at Macos
     
  3. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    I'd try using KeyCode.Space instead of providing "space" as a string to be parsed. Also, check if you don't have the same issue on a regular keyboard instead of that bluetooth one. I've seen plenty of weirdness from my own bluetooth keyboard devices not working with certain programs (unrelated to Unity).

    https://docs.unity3d.com/ScriptReference/KeyCode.Space.html