To achieve the required functionality, you just need to track the sequence of KeyPress events.
You can create a class to track the last key combination that was pressed in ProcessCmdKey . If this particular combination does not match the displayed command, but it is the first element of a sequence that you can save in your class. Then next time, ProcessCmdKey activated to check if the sequence has been started, check its new KeyPressTracker class. If it then checks to see if the recently pressed key combination is the second item you specify. The following is an example of pseudo code:
Step 1: ProcessCmdKey activated. The key combination is Ctrl + R , this does not correspond to the command that you want to process, but this is the first element of the sequence that you want to use ( Ctrl + R + M ).
Step 2: Save this keystroke in the new class that you created to track the last keystroke.
KeyPressTracker.Store(KeyCode, Modifiers);
Step 3: ProcessCmdKey activated a second time. This time, the key combination is Ctrl + M , which is not a keystroke that we are looking for, but is the second element of the sequence. We check the last saved keystroke using the new KeyPressTracker class. This will allow you to match a โsequenceโ such as Ctrl + R and Ctrl + M.
var lastKeyPress = KeyPressTracker.GetLastKeyPress(); if (lastKeyPress == "Ctrl+R" && currentKeyPress == "Ctrl+M") {
robowahoo
source share