Keyboard remapping
I like to use VIM as my editor. Alongside VIM I use TMUX to be able to have my preferred, keyboard-only setup (with the exception of googling for things which I haven't worked out how to do in the terminal yet).
I have found that rather than the default prefix of ctrl+b for tmux commands I prefer to use the backtick or grave. The problem is this isn't always in the top left as it is on standard keyboards. On my MacBook keyboard for example its in the bottom left (not as easy a place to reliably hit) and it doesn't exist on my 75 key mechanical keyboard.
This is fine, most of the time I remap escape on my mechanical keyboard to backtick and capslock to escape (This was the original location of escape when vim was first conceived).
When using things in vim I can always use the tilda to convert a long set of lowercase to uppercase if needed so the capslock is an underused key when compared to how often I end up using backtick.
The remapping on my Chromebook was rather simple, adding keyboards on there is a rather simple affair and the remapping is based on the ASCII value coming through, of which I'm already relatively familiar.
The mac on the other hand I have found to be far more frustrating.
https://stackoverflow.com/questions/4485972/library-launchagents-plist-runs-manually-but-not-automatically
https://apple.stackexchange.com/questions/281405/easy-way-to-remap-non-modifier-keys-on-mac
https://developer.apple.com/library/archive/technotes/tn2450/_index.html
<!--Put this file in ~/Library/LaunchAgents/com.example.KeyRemapping.plist to | |
automatically remap your keys when macOS starts. | |
See https://developer.apple.com/library/archive/technotes/tn2450/_index.html for | |
the key "usage IDs". Take the usage ID and add 0x700000000 to it before putting it | |
into a source or destination (HIDKeyboardModifierMappingSrc and | |
HIDKeyboardModifierMappingDst respectively).--> | |
<plist version="1.0"> | |
<dict> | |
<key>Label</key> | |
<string>com.example.KeyRemapping</string> | |
<key>ProgramArguments</key> | |
<array> | |
<string>/usr/bin/hidutil</string> | |
<string>property</string> | |
<string>--set</string> | |
<string>{"UserKeyMapping":[ | |
{ | |
"HIDKeyboardModifierMappingSrc": 0x700000039, | |
"HIDKeyboardModifierMappingDst": 0x700000029 | |
}, | |
{ | |
"HIDKeyboardModifierMappingSrc": 0x700000029, | |
"HIDKeyboardModifierMappingDst": 0x700000035 | |
}, | |
{ | |
"HIDKeyboardModifierMappingSrc": 0x700000064, | |
"HIDKeyboardModifierMappingDst": 0x700000035 | |
} | |
]}</string> | |
</array> | |
<key>RunAtLoad</key> | |
<true> | |
</true></dict> | |
</plist> |
/* | |
Copyright 2014 Google Inc. All rights reserved. | |
Copyright 2021 James Hylands | |
Licensed under the Apache License, Version 2.0 (the "License"); | |
you may not use this file except in compliance with the License. | |
You may obtain a copy of the License at | |
http://www.apache.org/licenses/LICENSE-2.0 | |
Unless required by applicable law or agreed to in writing, software | |
distributed under the License is distributed on an "AS IS" BASIS, | |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
See the License for the specific language governing permissions and | |
limitations under the License. | |
*/ | |
var contextID = -1; | |
chrome.input.ime.onFocus.addListener(function(context) { | |
contextID = context.contextID; | |
}); | |
chrome.input.ime.onKeyEvent.addListener( | |
function(engineID, keyData) { | |
var handled = false; | |
if(keyData.type == "keydown" && (keyData.key == "Escape" || keyData.key == "Esc")){ | |
if(keyData.ctrlKey){ | |
return false; | |
}else{ | |
chrome.input.ime.commitText({"contextID": contextID, | |
"text": "`"}); | |
keyData.preventDefault(); | |
handled = true; | |
} | |
} | |
return handled; | |
}); |
Comments
Post a Comment