Console.ReadKey() binds to Consolekeyinfo

Well im just trying to create some keybindings and save them down in a .json file.. everything works out great but somehow no matter what key i press to test it out it binds it to System.ConsoleKeyInfo instead of a real key press
18 Replies
Thinker
Thinker3y ago
Can you show the Keybindings class?
TroflineBlack
TroflineBlackOP3y ago
MODiX
MODiX3y ago
thinker227#5176
REPL Result: Success
Console.ReadKey().ToString()
Console.ReadKey().ToString()
Result: string
System.ConsoleKeyInfo
System.ConsoleKeyInfo
Compile: 430.771ms | Execution: 20.343ms | React with ❌ to remove this embed.
Thinker
Thinker3y ago
Ah, a key info doesn't have a ToString override
TroflineBlack
TroflineBlackOP3y ago
ohh.. so what should i do to fix this 😄
TroflineBlack
TroflineBlackOP3y ago
TroflineBlack
TroflineBlackOP3y ago
or does it not work? 😄
TroflineBlack
TroflineBlackOP3y ago
switching up string with var works.. but i cant switch string to var in here...
Thinker
Thinker3y ago
Wdym?
TroflineBlack
TroflineBlackOP3y ago
switching string into var here works..
TroflineBlack
TroflineBlackOP3y ago
TroflineBlack
TroflineBlackOP3y ago
he doesnt say anything then.. but then this not work xD
TroflineBlack
TroflineBlackOP3y ago
TroflineBlack
TroflineBlackOP3y ago
or idk.. im pretty much idealess 😄 need help :3
Thinker
Thinker3y ago
I think you should do Console.ReadKey().Key.ToString() That returns the name of the key as a string
MODiX
MODiX3y ago
thinker227#5176
REPL Result: Success
Console.ReadKey().Key.ToString()
Console.ReadKey().Key.ToString()
Result: string
A
A
Compile: 429.654ms | Execution: 30.809ms | React with ❌ to remove this embed.
Thinker
Thinker3y ago
As opposed to just Console.ReadKey().ToString() which doesn't return anything useful
TroflineBlack
TroflineBlackOP3y ago
works :3 tyty 😄

Did you find this page helpful?