Is there an easy way to get the corresponding keydata (keycode combination) for some value in that enum?
I cannot find one, and creating a switch statement for all those is a bit overkill...
The integer values of the enum elements are not keycodes, but some 'unknown' big numbers, so simply casting to int won't work.
System.Windows.Forms.Shortcut and System.Windows.Forms.Keys can be cast directly (their integer values match).
Keys keys = (Keys) Shortcut.CtrlL;
The lower 4 bytes are the key and the upper 4 bytes are a mask for Shift, Ctrl and Alt-Key, So you can get the KeyCode with something like this:
Shortcut shortcut = Shortcut.ShiftDel;
Debug.Print((((int)shortcut) & 0xFFFF).ToString());
Will output 46 which is the code for del key.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With