Mynotoar
Active member
I'm trying to make a class that produces a facsimile of the textbox from Winforms in Console. I have a loop within this class that is reading keypresses as ConsoleKeyInfo. What I want to do is to take a keypress and test whether it corresponds to an actual character. For example, the A key passes this test because it generates an a. Letters, digits, punctuation, symbols etc. are all fine, the only thing I don't want to accept are things like Home, Esc, Arrow keys, modifier keys, etc. This is essentially the solution I've got now, but as you can see it's hardly ideal.
Is there a way to refer to the set of keys that don't generate characters?
VB.NET:
Dim CKI As ConsoleKeyInfo
[COLOR=#00008B]Do
CKI = Console.Readkey(True)
If[/COLOR] [COLOR=#00008B]Char[/COLOR].IsLetterOrDigit(CKI.KeyChar) [COLOR=#00008B]Or[/COLOR] [COLOR=#00008B]Char[/COLOR].IsPunctuation(CKI.KeyChar) [COLOR=#00008B]Or[/COLOR] [COLOR=#00008B]Char[/COLOR].IsWhiteSpace(CKI.KeyChar) [COLOR=#00008B]Or[/COLOR] [COLOR=#00008B]Char[/COLOR].IsSymbol(CKI.KeyChar) [COLOR=#00008B]Then
[/COLOR]
[Run code]
[COLOR=#00008B] End[/COLOR] [COLOR=#00008B]If
Loop
[/COLOR]
Is there a way to refer to the set of keys that don't generate characters?