Is there any way for me to assign both keyboard shortcut to the same menu bar item?
Though normal methods I would have to say no, and I do not know of an abnormal method that would allow it either.
- Create an Automator Quick Action/Service with settings:
- Workflow receives [no input] in [Notes]
- Add a Run AppleScript action, replacing the default code with:
tell application "System Events" to key code 4 using command down
tell application "System Events" to set visible of application process "Notes" to false
Save the workflow as, e.g.,: Hide Windows in Notes
In System Preferences > Keyboard > Shortcuts > Services > App Shortcuts, add one for Notes and the Close menu title setting it keyboard shortcut to: ⌘U
In System Preferences > Keyboard > Shortcuts > Services, set the keyboard shortcut for, e.g., Hide Windows in Notes to: ⌘W
Now when in Notes and you press ⌘W it hides the windows instead of closing the window.
On some versions of macOS there is a bug in the naming convention of an Automator Quick Action/Service in that spaces cause the Quick Action/Service not to show in System Preferences > Keyboard > Shortcuts > Services. The workaround is to not use spaces in the name of the Quick Action/Service.
The example AppleScript code, shown above, was tested in Script Editor and an Automator Quick Action/Service under macOS Catalina with Language & Region settings in System Preferences set to English (US) — Primary and worked for me without issue1.
- 1 Assumes necessary and appropriate settings in System Preferences > Security & Privacy > Privacy have been set/addressed as needed.