Input.GetKeyDown() and Input.GetKeyUp() dosent work every every time

Sobasicly when I run the code when I press ‘w’ it doesn’t always detect it and it doesn’t print down and when I realise ‘w’ it doesn’t print up so I’m a bit confused. Don’t know if it’s my code or just something wear with my keyboard so please help me. This my code:

@Kisielekw, Your code looks fine, unless grounded is not what you expect, so grounded may be the issue. Debug grounded before the if statement.

Just a personal style note - this is not the problem - but for consistency I use the Double Ampersand && for a Conditional AND. Its fine with a single & with booleans, but with anything else it is a Logical AND operation

 // in the case of booleans && and & are the same
 // but as a matter of style
 if(  Input.GetKeyDown("w") && grounded )
  //  don't need to test for grounded == true because grounded is a boolean.