Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there a way to use normal keys as modifier keys? Assuming my keyboard correctly records my pressing S and F together, is there a way for me to use the combination as a keyboard shortcut like Ctrl+S?

Specifically:

  • How do I test that my keyboard is capable of detecting simultaneous keypresses?
  • How can I remap the combination so that it can be used by an application like Emacs?
share|improve this question
    
Autokey baby. . . –  surfasb Oct 2 '11 at 8:38
    
care to elaborate, honey? –  TomSW Oct 2 '11 at 22:18

1 Answer 1

Q: How do I test that my keyboard is capable of detecting simultaneous keypresses?

A: You could use KeyCodes to monitor what Windows sees when pressing keyboard keys. In the picture below are three keys pressed simultaneously. OnKeyDown meens it's currently pressed and OnKeyUp triggers when you release the button.

enter image description here


Q: How can I remap the combination so that it can be used by an application like Emacs?

One possible way is to use AutoHotKey. I recommend the portable version of AutoHotKey to avoid the installation of additional software

The example shows how to remap key A to key B

A::SendInput {B}

It's also possible to add modifiers like Win(#), Alt(!), Ctrl(^) or Shift(+). Read the AHK manual section HotKeys for more info

+!A::SendInput {B}

Our main problem is that AHK cannot bind more than one base key. Base keys are all keyboard keys except modifier keys.

Luckily there is a trick. We only use S to trigger a small macro where we next check if F is pressed. If yes, we send our new key combination Ctrl+S

~S::
  GetKeyState, state, F
  if state = D
  SendInput ^{s} 
Return

~F::
  GetKeyState, state, S
  if state = D
  SendInput ^{s} 
Return
  • The downside is we have to do this for the other way around too where F is pressed first and then S
  • Don't forget the tilde ~ in front of a key which means the native function should not be blocked
  • Don't send an uppercase ^{S} or else AHK will send an additional Shift keystroke. I have no clue why. However, a lowercase ^{s} works as expected

Here is a AutoHotKey beginners guide on Youtube together with some useful links

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.