'How can I query for keyboard input in a GUI app without using a pre-built input form?

In a console app, I could put Console.ReadKey() in an infinite loop, and I have what I wanted. But how can I do that in a GUI app?

Let's say I'm using the new MAUI framework and I want to implement a text box from scratch. How could I query for user input? Since I'm reinventing a text form, the first step is to receive continuous, key-by-key input.

In a game engine, like Unity, you're given an input class, and you could check if and which key was pressed every frame. What's a .NET equivalent?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source