简体   繁体   中英

cmd (telnet client) detect function keys (F1…F12) c#

I've followed this GitHub for an example of telnet server in Visual Studio C#. https://gist.github.com/UngarMax/6394321573dc0791dff9

I'm using cmd.exe to act as the client (running this command: telnet localhost 23). Alternatively it can run using telnet.exe (running this command: open localhost 23)

The above code allows user to input any message and press enter, if the message found, it will load the desire screen. Now I need to detect F1..F12 as a message to the server so that it can load the correct page. Anyone has any idea on it?

PS: I have tried detecting F1's hex code (0x70) but it doesn't really work.

See this article: How to handle key press event in console application

You can detect F Keys with

if (keyinfo.Key == ConsoleKey.F1)
            {
                //do something
            }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM