작성일: 2024년 1월 9일
Macbook에 USB Keyboard나 Bluetooth Keyboard를 연결해서 사용하다보면,
Home과 End Key가 MS Windows와 달라서 불편하다.
Karabiner-Elements App을 설치하면 원하는대로 Key를 변경할 수 있지만, 나는 Macbook에 이것저것 App 설치하는 것이 싫어서 설정 파일을 직접 작성해서 Home, End Key 설정을 변경했다.
나중에 까먹고, 또 검색하느라 시간을 허비할 것 같아서 여기에 메모해둔다.
## 아래의 순서로 명령을 실행한다.
$ cd ~/Library
$ mkdir KeyBindings
$ cd KeyBindings
$ cat << EOF >> DefaultKeyBinding.dict
{
/* Remap Home / End */
"\UF729" = "moveToBeginningOfLine:"; /* Home */
"\UF72B" = "moveToEndOfLine:"; /* End */
"$\UF729" = "moveToBeginningOfLineAndModifySelection:"; /* Shift + Home */
"$\UF72B" = "moveToEndOfLineAndModifySelection:"; /* Shift + End */
}
EOF
$
위와 같인 .dict 파일을 생성했으면, Log Out하고 다시 Log In 한다.
그러면 Home Key와 End Key의 설정이 바뀌어 있을 것이다.
더 자세한 내용은 아래 Git 문서를 참고하기.
https://gist.github.com/trusktr/1e5e516df4e8032cbc3d
위 Git 문서에서 중요한 부분만 발췌했다.
/* ~/Library/KeyBindings/DefaultKeyBinding.Dict
This file remaps the key bindings of a single user on Mac OS X 10.5 to more
closely match default behavior on Windows systems. This makes the Command key
behave like Windows Control key. To use Control instead of Command, either swap
Control and Command in Apple->System Preferences->Keyboard->Modifier Keys...
or replace @ with ^ in this file.
Here is a rough cheatsheet for syntax.
Key Modifiers
^ : Ctrl
$ : Shift
~ : Option (Alt)
@ : Command (Apple)
# : Numeric Keypad
Non-Printable Key Codes
Standard
Up Arrow: \UF700 Backspace: \U0008 F1: \UF704
Down Arrow: \UF701 Tab: \U0009 F2: \UF705
Left Arrow: \UF702 Escape: \U001B F3: \UF706
Right Arrow: \UF703 Enter: \U000A ...
Insert: \UF727 Page Up: \UF72C
Delete: \UF728 Page Down: \UF72D
Home: \UF729 Print Screen: \UF72E
End: \UF72B Scroll Lock: \UF72F
Break: \UF732 Pause: \UF730
SysReq: \UF731 Menu: \UF735
Help: \UF746
OS X
delete: \U007F
For a good reference see http://osxnotes.net/keybindings.html.
NOTE: typically the Windows 'Insert' key is mapped to what Macs call 'Help'.
Regular Mac keyboards don't even have the Insert key, but provide 'Fn' instead,
which is completely different.
*/
{
"@\UF72B" = "moveToEndOfDocument:"; /* Cmd + End */
"~@\UF703" = "moveToEndOfDocument:"; /* Cmd + Option + Right Arrow */
"@$\UF72B" = "moveToEndOfDocumentAndModifySelection:"; /* Shift + Cmd + End */
"@\UF729" = "moveToBeginningOfDocument:"; /* Cmd + Home */
"~@\UF702" = "moveToBeginningOfDocument:"; /* Cmd + Option + Left Arrow */
"@$\UF729" = "moveToBeginningOfDocumentAndModifySelection:"; /* Shift + Cmd + Home */
"\UF729" = "moveToBeginningOfLine:"; /* Home */
"~\UF702" = "moveToBeginningOfLine:"; /* Option + Left Arrow */
"$\UF729" = "moveToBeginningOfLineAndModifySelection:"; /* Shift + Home */
"$~\UF702" = "moveToBeginningOfLineAndModifySelection:"; /* Shift + Option + Right Arrow */
"\UF72B" = "moveToEndOfLine:"; /* End */
"~\UF703" = "moveToEndOfLine:"; /* Option + Right Arrow */
"$\UF72B" = "moveToEndOfLineAndModifySelection:"; /* Shift + End */
"$~\UF703" = "moveToEndOfLineAndModifySelection:"; /* Shift + Option + Left Arrow */
"\UF72C" = "pageUp:"; /* PageUp */
"\UF72D" = "pageDown:"; /* PageDown */
"$\UF728" = "cut:"; /* Shift + Del */
"$\UF727" = "paste:"; /* Shift + Ins */
"@\UF727" = "copy:"; /* Cmd + Ins */
"$\UF746" = "paste:"; /* Shift + Help */
"@\UF746" = "copy:"; /* Cmd + Help (Ins) */
"~j" = "moveBackward:"; /* Option + j */
"~l" = "moveForward:"; /* Option + l */
"~i" = "moveUp:"; /* Option + i */
"~k" = "moveDown:"; /* Option + k */
"@~i" = ("moveUp:","moveUp:","moveUp:","moveUp:","moveUp:","moveUp:","moveUp:","moveUp:",); /* Cmd + Option + j */
"@~k" = ("moveDown:","moveDown:","moveDown:","moveDown:","moveDown:","moveDown:","moveDown:","moveDown:",); /* Cmd + Option + j */
"@\UF702" = "moveWordBackward:"; /* Cmd + LeftArrow */
"@~j" = "moveWordBackward:"; /* Cmd + Option + j */
"@\U007F" = "deleteWordBackward:"; /* Cmd + Backspace */
"@\UF703" = "moveWordForward:"; /* Cmd + RightArrow */
"@~l" = "moveWordForward:"; /* Cmd + Option + l */
"@\UF728" = "deleteWordForward:"; /* Cmd + Delete */
"@$\UF702" = "moveWordBackwardAndModifySelection:"; /* Shift + Cmd + Leftarrow */
"@$\UF703" = "moveWordForwardAndModifySelection:"; /* Shift + Cmd + Rightarrow */
}
'MacOS' 카테고리의 다른 글
macOS용 키보드 추천 - keychron(키크론), 타겁샵 추천 (0) | 2021.11.19 |
---|---|
Linux, Mac OS 터미널에 글자 컬러 효과 넣기 (0) | 2021.11.18 |
Mac OS iTerm2 에서 한글 음소 분리(깨짐) 현상 해결 방법 (0) | 2021.11.18 |
DP 케이블을 이용해서 맥북 프로와 모니터 연결 방법 (0) | 2021.09.14 |
Trackpad scroll direction change (0) | 2021.07.10 |