The Ctrl key is mapped to the Enter function by default for the 3270 and 5250 emulators. Because Java does not distinguish between left and right Ctrl keys, this change means that both Ctrl keys now act as Enter. You can still remap Ctrl or use it in combination with another key, and you can still remap the Enter function to any other key. The best solution I found was the free KeyRemap4MacBook utility- it lets you change the keyboard in many ways.My personal modifications (for the MacBook Air 2012 model): 'fn + cursor left/right' for Home/End and 'fn + up/down' for PgUp/PgDown, via For PC Users: Use PC Style Home/End, Use PC Style PageUp/PageDown; switching the function keys to work like on 'PC'.
Click here to return to the '10.4: Remapping keys in Mac OS X 10.4' hint |
Finally I can reassign that dreadful Enter key on my MBP to nice and useful Option key! Thank you!
Tell me, how exactly am I supposed to remap the Caps Lock key to the Escape key using DoubleCommand? :P
Be warned that DoubleCommand issues a kernel panic on boot with the lastest Mac OS X 10.4.7 on Intel machines, at least on my two laptops
I found the utility to be extremely useful until I found myself without the capability of booting my Macbook :(
Awesome.
I'm sure that it drove you nuts, but it was fun to read...
I'm glad to hear it. :)
of course, the use of Apple's Plist Editor (I think every MOXH.com reader should know it, othervise it comes with developer tools) will spare you time about the conversion and Terminal stuff!
BTW: Does anyone know is it possible to remap multimedia keys?
(extra buttons that are ment to control Explorer/Media Player/Clipboard on Windows)
These seem to be very different than usual keys (Ukelele keyboard remapper doesn't see them pressed)
Be warned that the code 16, when used as the destination of a mapping, actually causes a kernel panic on keypress -- as I've found out the hard way.
Hmm... do I smell a future April Fool's Trick?? ;-) This is an absolutely horrible april fools joke. A good joke doesn't crash a system, it pranks it. Search for 'cocoa text system' for a hint with lots of pranking capabilities. Remapping the shift button to number pad 0 or something might be pretty good. But a kernel panic button… that's just cruel, in the worst way.
I feel the same way. A good prank can be undone by the victim, but this kernel-panic inducer would be too cruel because it'd be so hard to troubleshoot. Analogy: it's ok to saran-wrap a coworker's cube, because she can unwrap it, but not ok to spray-paint her cube or fill it with concrete.
A good prank idea: Back in oS9 days, I snuck a pair of Applescripts onto a coworker's machine. One of them set the Date and Time options to announce the time [every 15 min. I think]. The other script detected when the first script was deleted, and restored it immediately. It took her a few hours, not that she tried that hard, but she eventually found 'em both. Now that's a prank, and I would only have done it to her or one other person, the only 2 users I knew who were savvy enough to know where to look for the prank's parts.
Incidentally, the latest DoubleCommand (at the link above) works perfectly for me on a Macbook Pro + 10.4.8.
why am i just now learning about this hint?
caps lock = esc
1. remap caps lock to help
2. quicksilver trigger this script:
tell app 'System Events' to key code 53
3. set 'hot key = help' and 'activate = on release'
Is there a way to make arbitrary keys behave as modifier keys? I'm left-handed and my setup doesn't really allow me to have a full-size external keyboard, so I'd like to buy a USB numeric keypad and assign the frequently used modifier keys (cmd, opt, ctrl, fn and shift) to the keys on the keypad.
I looked into DoubleCommand and fKeys and Keyboard Maestro, none of which fit the bill. Perhaps there's a clever hack that strings multiple things together for a solution?
Anyone?
I really need this, so sorry for opening an old post. Anyone have any instruction updates for 10.5.7 in simple easy to understand steps? I'm a terminal newbie but have Apple's Property List editor if that helps. The .global files (I have several) referred to in this hint show no signs of having a 'com.apple.keyboard.modifiermapping key' entry on my system.
I just want to make my right option key act as the enter key which they removed from the newer laptops. Any help is really appreciated, Thanks.
- I created a new dead key map for 'keypad 0'.
- Then, for each key in the dead key map, I added  (ESC) plus the key itself
- For instance, the dead key for 'a' is configured as a (ESC + A)
I bought a new Apple keyboard which has an extra tilde key to the left of the z and before the shift key which is now much less wide than the standard shift key I'm used to. I'd like to remap the tilde key to the left of my Z to also function as a shift key. Is there any way I can do this?
This still works with more recent OSX versions. There is no need to convert the plist to XML, just find the most recent ~/Library/Preferences/ByHost/.GlobalPreferences.*.plist file, open it in the PropertyList Editor (double-click or call with open), find the section(s) com.apple.keyboard.modifiermapping.* (one for each keyboard), open the section, and copy/paste item entries, modifying as indicated in the hint. Save when finished.For me, I swap Caps Lock and Control, but wanted the right Control key (just left of the arrow keys) to retain functionality as a Control key. So I simply highlighted and deleted the Item mapping between them, and saved; worked perfectly after a logout. Tested on Snow Leopard.
Starting with 10.12 Sierra, macOS comes with the hidden and surprisingly flexible feature allowing remapping arbitrary keyboard keys. This feature is not exposed anywhere in the system UI. Yet it is available to everyone via simple hidutil
built-in command controlling IOHIDFamily driver, requiring no hardware modifications or tampering with System Integrity Protection.
Mac Remap Keyboard Keys
I use Mac at home, Windows at work and I often interact with Linux. I use function key shortcuts quite a lot in various file managers and programming IDEs. In the same time, I want my screen brightness to be adjustable on my Mac with a single key press. Finally, on top of that I often type Polish text, which requires using right alt that is hardly reachable with the right thumb as it is farther right than on PC/Windows keyboard. Yes, I am quite demanding.
All what I want could be expressed by the following Mac key remapping, that:
- Keeps F1 and F2 for brightness adjustment, but leaves other function keys accessible directly, without fn,
- Remaps right ⌘ to ⌥ option, so Mac letter modifier is at same place as on PC/Windows keyboard, closer to the space key and much easier reachable with the right thumb.
Function keys on macOS
Figure 1: Apple Magic Keyboard function keys depicted in How to use the function keys on your Mac.
By default on macOS, Apple keyboard function keys act as media/OS control keys that modify screen brightness, volume, etc. Standard function keys are accessible holding fn modifier. This is not a problem when working with native macOS apps, rarely using F1-F12, but becomes cumbersome when using some cross platform software, or interacting remotely with the other operating systems and applications relying a lot on standard function keys.
fn behavior can be reversed with System Preferences “Use F1, F2, etc. keys as standard function keys” switch, that makes standard function key behavior primary and media/OS behavior secondary, hence requiring fn modifier. Unfortunately, there is no switch that lets you adjust this behavior individually for the each function key.
There are some macOS applications addressing this, e.g. Function Flip or making function key behavior application specific e.g. Fluor. There are also some programs that let you remap other individual keys e.g. keyremapd of mine.
All of them use rather tricky macOS system level event hooks, and obviously require some helper application running in the background. So far I relied on my own keyremapd solution, but with recent macOS releases it began to act in a quite erratic way. Therefore, without further ado, I started to look for some alternatives.
IOHIDKeyboardFilter and hidutil
macOS since 10.12 Sierra provides quite interesting low-level built-in feature allowing to create custom keyboard remapping without a need for additional software. Everything is a part of IOHIDFamily driver and is nicely described by a Tech Note. Additionally, this driver is open-source, so the underlying details are freely accessible reading IOHIDKeyboardFilter.mm source code.
I believe this feature exists thanks to some smart Apple engineers who are power-users at the same time and realize that a simple System Preferences switch may be not enough for everyone. There is no system UI that exposes this custom keyboard remapping feature though.
Interestingly, both custom remapping and function key mapping with fn happens essentially in the same place in IOHIDKeyboardFilter.mmIOHIDKeyboardFilter::remapKey
. Everything is driven by the magic HID page and usage numbers - expressed with 64-bit (or 32-bit) codes. Internally, remapKey
applies the mapping according to FnFunctionUsageMap
table exposed by the attached USB HID compatible keyboard. This table can be printed with:
NOTE: Output above is for 1st gen Apple Magic Keyboard. Comments starting with #
added by me for extra readability. Other keyboards can produce different output.
Left column is 32-bit HID function key code that consists of upper 16-bit HID page number (key group), lower 16-bit HID usage number (individual key code). Right column is 32-bit media key code, also composed of two 16-bit HID page and usage numbers. Meaning of these codes can be found e.g. in FreeBSD USB HID usage table.
Depending on fn state, the left or right key code is emitted by the driver. Everything happens in the software and can be later further customized by UserKeyMapping
that is applied right after the fn mapping in IOHIDKeyboardFilter.mmIOHIDKeyboardFilter::remapKey
function.
UserKeyMapping details
Custom user key mapping can be provided to IOHIDFamily driver from command line using macOS built-in hidutil
e.g. as described in the Tech Note:
The example mapping above swaps A and B keys, mapping A→B (1st mapping) and B→A (2nd mapping). This is very simple example, but UserKeyMapping
supports any one-to-one mapping that can be expressed using USB HID usage table codes.
NOTE:UserKeyMapping
uses 64-bit values (rather than 32-bit as UserKeyMapping
). Upper 32-bit part is HID page number, lower 32-bit is HID usage number. Therefore, 32-bit values provided by FnFunctionUsageMap
have to be padded with extra zeros up to 64-bit number.
All above leads me to the following mapping satisfying my demands stated in the beginning:
NOTE: This recipe is quite lengthy as I remap each media and function key in both directions.
Such mapping is effective until next reboot, or hidutil
call, to make it persistent e.g. active after login, following ~/Library/LaunchAgents/com.nanoant.KeyRemapping.plist
launch agent can be used:
Summary
Originally I wanted to put “easy” in the title of this post, but I am not sure if this solution is really straightforward to everyone. But I believe this is something that should be relatively clear to any programmer or engineer working with various number representations and familiar with command line environment. Personally I find it much more robust than using any third party software. And as long UserKeyMapping
remains in IOHIDFamily driver, that remains open-source, this is my preferred approach.
Remap Mac Keyboard
I am aware I am not the first one that “discovers” this nice built-in macOS feature. Nevertheless, I decided to write this “longish” explanation in hope that someone else finds it helpful. I will also appreciate any feedback in the comments section below.