0

I am currently trying to get real-time keyboard input (both press, hold, and release) in a C# console application. I've found a way that works using only Console.ReadKey(). Problem is that windows sets a delay before a key is repeated. I have found various other questions asking how to change this in code, but all the answers simply tell you to use the built in press, release, and hold events in a windows forms application. I can't use those in console.

As a note, i do not know much about API coding or DLL's.

See this previous post by me for further motivation if you need it to answer: C# Console application: Console.Readkey() has odd initial skipping behaviour on high framerates

Buster Bie
  • 121
  • 4
  • this might be useful: https://codereview.stackexchange.com/questions/127914/getting-keyboard-input-for-real-time-console-application – jazb Oct 26 '18 at 07:40
  • Have you tried using some kind of event model instead of readkey? See: https://stackoverflow.com/questions/8898182/how-to-handle-key-press-event-in-console-application – fstam Oct 26 '18 at 07:41
  • There are teh low level "Keyboard Hooks", wich allow you to to get Keyboard presses even when out of focus and even before the Windowing Sytem is informed. However they require stepping deeply outside of managed code and into the Windows API. – Christopher Oct 26 '18 at 07:49
  • @JohnB Thanks. Unfortunautely that was actually the post that inspired me to use Console.ReadKey() to begin with. Is it the second codeblock with various intrepreter, UI, and update functions that i am supposed to note? – Buster Bie Oct 26 '18 at 07:50
  • i think the `Windows API` is calling you... – jazb Oct 26 '18 at 07:52
  • @JohnB Would it be possible to give a code example (completely understandable if not, and the amount of code and work required might be extensive) as i have never done API coding. This is the only thing i need for the project, and while i recognize that is is possible for me to learn API coding, it would be many prerequisites and much time for this one small thing for an exam project. – Buster Bie Oct 26 '18 at 07:59

0 Answers0