I need a function that takes a String as an argument, and returns a System.Windows.Input.Key. E.G:
var x = StringToKey("enter"); // Returns Key.Enter
var y = StringToKey("a"); // Returns Key.A
Is there any way to do this other than if/else’s or switch statements?
Take a look at KeyConverter, it can convert a
Keyto and from astring.