I am using Visual Studio 2010 to create a visual C # application, and I want to include some parameters in my application settings for customizing keyboard shortcuts using some kind of text box input. I understand how to write keyboard input and how to save it in the settings of the user application, but I can not find any input controls that have this functionality.
those. something like that:
But using Windows forms (Note: above from Divvy for OS X from the app store).
Is there any built-in functionality for this? Are there any good libraries or user inputs that I could use?
Otherwise, any suggestions on how to implement something like this?
Decision:
Using Bas B answer and some other logic:
private void fShortcut_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode != Keys.Back) { Keys modifierKeys = e.Modifiers; Keys pressedKey = e.KeyData ^ modifierKeys; //remove modifier keys if (modifierKeys != Keys.None && pressedKey != Keys.None) { //do stuff with pressed and modifier keys var converter = new KeysConverter(); fShortcut.Text = converter.ConvertToString(e.KeyData); //At this point, we know a one or more modifiers and another key were pressed //modifierKeys contains the modifiers //pressedKey contains the other pressed key //Do stuff with results here } } else { e.Handled = false; e.SuppressKeyPress = true; fShortcut.Text = ""; } }
The above method indicates when a valid combination of shortcuts is entered, checking whether both modifier keys and the other key are pressed.
source share