CoRD icon indicating copy to clipboard operation
CoRD copied to clipboard

Feature Request: keyboard "normalization"

Open ghost opened this issue 13 years ago • 3 comments

Some feature to "Normalize" the Apple CMD with the Windows CTRL would be very, very helpful. Preferably, this would be a solution to causes the remote Windows keyboard behavior to align with the local Apple OS X actions.

I've implemented one possible approach as a "hack" to CoRD local copy of CoRD. My keyboard "normalization" hack does the following at a global level:

  1. All Apple CMD-<some_key> are passed through as Microsoft Windows CTRL-<some_key>
  2. No Microsoft LWIN or RWIN key events are generated. (My personal bias is to literally remove the Microsoft WINdows key from the keyboard. Something which Window gamers do to avoid the Start menu or Window minimize suddenly happening during a game. :-)
  3. Disable ALT keyboard navigation. (Again, this is my personal bias to not have these underlined letter pseudo "sticky key" keyboard navigation ever present to divert what I was meaning to do while typing.)

One side effect is that the local CoRD menu key equivalents need to be reconsidered. In my case, I prefer replacing 'Copy CMD-C' with 'Copy (From Remote) CTRL-CMD-C'. The term "Copy (From Remote)" is more expressive of the desired action. And, 'CTRL-CMD-C' with two flags is a reminder that the action is bridging two systems.

On my local hack, I've removed most local key equivalents. In practice, the local menu are used far less frequently than the remote menus with logged into a remote machine. For the local menu key equivalents which remain, I use the CTRL or CTRL-CMD instead of CMD.

Note: The above normalization frees up the local CTRL key (CMD takes over and WIN is never generated)... therefore the CTRL key can be used for any desired local key equivalents without interfering with controlling the remote machine.

Below is the "hack" which I'm using for the above feature on a local copy of CoRD.

//// constants.h ////

define KBD_FLAG_UP 0x8000

// :EDIT:BEGIN:

define KBD_FLAG_CTRL 0x0020

define KBD_FLAG_WIN 0x0080

// :EDIT:END:

//// CRDKeyboard.m ////

  • (void)sendScancode:(uint8)scancode flags:(uint16)flags { // :EDIT:BEGIN: // NORMALIZE THE APPLE AND WINDOWS KEYBOARD

    // Suppress ALT key ... as a key.
    // This avoids invoking the ALT keyboard navigation. // Display > Apperance > Effects > [√] Hide underline letters for keyboard navigation... if ((scancode == SCANCODE_CHAR_LALT) || (scancode == SCANCODE_CHAR_RALT)) return;

    // ALT modifier flag is not suppressed or modified. // Some additionals steps are need for CMD-ALT- to properly pass from local to remote machine

    // Suppress CNTRL key ... as a key. if ((scancode == SCANCODE_CHAR_LCTRL) || (scancode == SCANCODE_CHAR_RCTRL)) return;

    // Remap CTRL scancode to come from the CMD (Apple Command/Microsoft WINdows) if (scancode == SCANCODE_CHAR_LWIN) scancode = SCANCODE_CHAR_LCTRL; if (scancode == SCANCODE_CHAR_RWIN) scancode = SCANCODE_CHAR_RCTRL;

    // swap KBD_FLAG_CTRL (0x20) with KBD_FLAG_WIN (Apple CMD 0x80) if ((flags & (KBD_FLAG_WIN | KBD_FLAG_CTRL)) == (KBD_FLAG_WIN | KBD_FLAG_CTRL)) { ; // if both flags are set then no swap needed } else if (flags & KBD_FLAG_CTRL) { flags &= ~(KBD_FLAG_CTRL); // bitwise clear flags |= KBD_FLAG_WIN; // bitwise set } else if (flags & KBD_FLAG_WIN) { flags &= ~(KBD_FLAG_WIN); // bitwise clear flags |= KBD_FLAG_CTRL; // bitwise set } // :EDIT:END:

AH, WHAT A RELIEF, TO NOT BE CONSTANTLY SWITCHING BETWEEN CMD-C AND CTRL-C FOR WHAT IS OTHERWISE THE SAME FUNCTION.

ghost avatar Feb 16 '12 00:02 ghost

This would be a great feature to have, but in the mean time I found a decent workaround. Install KeyRemap4MacBook (http://pqrs.org/macosx/keyremap4macbook/). The developers of KeyRemap4MacBook made their application aware of CoRD specifically (I checked the default XML configuration) but CoRD is lumped in with other Remote Desktop Connection software so you won't see CoRD mentioned in the GUI.

Once KeyRemap4MacBook is installed, open it's preferences and go into the "For Applications" section. Expand the "Enable at only Remote Desktop Connection Client" section and check/uncheck the options there to match your personal preferences. I checked all three options myself. In CoRD, open preferences and uncheck the "Send Command Key" option. Copy, paste, etc. with the command key will now work in CoRD when connected to a remote server. The downside is you won't be able to copy/paste normally when in CoRD's connection Inspector and you lose the functionality of Windows key shortcuts (Win+R, Win+E, etc.) in your Remote Desktop session.

It's far from perfect but I think I can live with the shortcomings for now.

andyzib avatar May 02 '12 15:05 andyzib

@hopscotch I'm loving your work here - have made the changes as above to a local build and like you am finding this something of a relief...

Being a copy-and-paste developer I don't really understand much of what you're doing, and would be even happier if cmd-S would act as CTRL-S on a remote machine - I seldom make changes to CoRD, so don't need cmd-S to save changes there, and having to use alt-cmd-S to save remotely is a bit of a pita...!

Thanks for this - it's a great step forward and any further guidance greatly appreciated...!

steveWinter avatar Jun 12 '12 23:06 steveWinter

I'd very much like to see this become a feature or at least option in CORD to align it further with other remote access solutions (Synergy, CotVNC, TigerVNC, Microsoft RDP) which perform this kind of normalisation to allow local keyboard shortcuts to function on the remote host seamlessly.

homotechsual avatar Aug 16 '13 13:08 homotechsual