© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
20 replies
aaron

❔ Console.ReadKey() blocking

Hey there. I have this function that is called every frame:

public void Update()
{
    if ( !Console.KeyAvailable ) return;

    var key = Console.ReadKey(intercept: true);
}
public void Update()
{
    if ( !Console.KeyAvailable ) return;

    var key = Console.ReadKey(intercept: true);
}


It blocks until a key is pressed instead of setting KeyAvailable back to false...

I know this is being called every frame because I can insert a
Debug.Log(); return;
Debug.Log(); return;
at the top and I will see it log every frame.

However if I put the
Debug.Log()
Debug.Log()
after the
ReadKey()
ReadKey()
, it only gets called when you press keys.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Console.ReadKey() binds to Consolekeyinfo
C#CC# / help
4y ago
❔ Console.ReadKey not working with key modifiers
C#CC# / help
3y ago
ReadKey() input question [Answered]
C#CC# / help
4y ago
✅ Event-like event for ReadKey
C#CC# / help
3y ago