Dean
Dean

Reputation: 301

Check if a String is a Keyboard shortcut

Is there any possible way (like a method from another class) where one would be able to check if a text such as Shift + Ctrl + D is a Keyboard shortcut?

I have a couple of Keyboard shortcuts saved in a textfile. Now I want to cycle through each line and make sure that the string is indeed a shortcut, and not just some gibberish text like hello world.

Previously I used the ConvertToString method from the KeyConverter class to convert e.KeyValue to a string, but it doesn't seem like they have a method to reverse it.

Upvotes: 0

Views: 190

Answers (1)

Callum Watkins
Callum Watkins

Reputation: 2991

The KeyConverter class has a ConvertFromString function which you can use to reverse the conversion.

It should throw a NotSupportedException if the string is invalid.

Upvotes: 1

Related Questions