How to disable keyboard shortcuts in mac os x

社会主义新天地 提交于 2019-12-04 07:33:48

问题


I would like to disable keyboard shortcuts command-w and command-q in mac os x 10.8, mountain lion. This is because they interfere with emacs commands which I run from inside a terminal running from xQuartz. All help will be appreciated.


回答1:


BetterTouchTool is no longer free.

I reached this page because I wanted to disable command-h (hide application) which is not shown in System Preferences. This is my solution.

BetterTouchTool is a utility which can disable keyboard shortcuts (and has many other uses). http://www.boastr.de/

To disable command-w globally

  1. Install BetterTouchTool
  2. Click on the BetterTouchTool menubar item and choose "Preferences"
  3. Click "Gestures"
  4. Click "Keyboard"
  5. Click "Global"
  6. Click "Add New Shortcut"
  7. Click "Keyboard Shortcut"
  8. Type the shortcut you want to disable (for example, command-w)
  9. Set Trigger Predefined Action to "No Action" (which is the default)

Note that you can also set a keyboard shortcut for a specific application.

To disable command-w only for Terminal

  1. Install BetterTouchTool
  2. Click on the BetterTouchTool menubar item and choose "Preferences"
  3. Click "Gestures"
  4. Click "Keyboard"
  5. Click the plus sign at the bottom of the "Select Application" pane
  6. Choose Terminal (in Applications/Utilities folder)
  7. Click "Add New Shortcut"
  8. Click "Keyboard Shortcut"
  9. Type the shortcut you want to disable (for example, command-w)
  10. Set Trigger Predefined Action to "No Action" (which is the default)



回答2:


BetterTouch wasn't able to change or disable the key that was causing me grief: ctrl-cmd-d.

Here is how I was able to delete it:

  1. Edit ~/Library/Preferences/com.apple.symbolichotkeys.plist (you can use Xcode).
  2. Find the code for kCGHotKeyLookUpWordInDictionary (70), and set 'enabled' to OFF (if it's not there just create an entry '70' with 'enabled' = OFF).
  3. Restart your system

From this site I learned about symbolic hot keys and found a list of them: http://www.theregister.co.uk/2009/02/24/hotkeys_framework2/

These sites have lists of the codes used in the plist file, so one can actually change the shortcuts instead of only deleting them: http://krypted.com/mac-os-x/defaults-symbolichotkeys/ http://hintsforums.macworld.com/archive/index.php/t-114785.html




回答3:


To view or change Keyboard shortcuts:

  1. Open the System Preferences->Keyboard
  2. Click on the Keyboard Shortcuts tab
  3. To change a shortcut, double click on the existing shortcut, and press the keys that make up your new shortcut.
  4. If you make a mistake, click '"Restore Defaults to return the keyboard shortcuts to the factory defaults



回答4:


A solution that may work for factory hotkeys in individual apps which conflict with your desired assignment:

Use the built-in hotkey management:

System Preferences | Keyboard | Shortcuts | App Shortcuts

...to map the pre-existing to some hard-to-hit keyboard combination (like Cmd-Opt-Shift-backslash). This will free-up the old key combination for assignment.




回答5:


Which highly recommend is hammerspoon, who defined GOD LIKE!

  1. install hammerspoon

  2. vim ~/.hammerspoon/init.lua

  3. paste this hs.hotkey.bind("cmd", 'H', function()end) in

  4. :wq and then StatusBar -> Hammerspoon -> ReloadConfig

  5. done!

Happy Hack!




回答6:


A solution is to configure XQuartz to enable "Option keys send Alt_L and Alt_R" under Preferences/Input.

Then add this to your ~/.emacs:

(setq x-alt-keysym 'meta)

It is not perfect, as you might still slip on Cmd-W instead of Option-W sometimes, but at least it is functional.




回答7:


Following an article on how to script shortcuts I tried setting a shortcut to '' to no avail, but setting it to NULL worked fine. Here's an example:

TAB_KEY_SYMBOL="\\U21e5"
COMMAND_KEY_SYMBOL="@"
SHIFT_KEY_SYMBOL="$"

defaults write com.apple.finder NSUserKeyEquivalents "{ 'Show Package Contents' = '${COMMAND_KEY_SYMBOL}${SHIFT_KEY_SYMBOL}O'; }"

defaults write com.apple.finder NSUserKeyEquivalents -dict-add 'Add to Sidebar' '\U0000'
defaults write com.apple.finder NSUserKeyEquivalents -dict-add 'Add to Dock' '\U0000'

# kill finder and prefs daemon
killall Finder
killall cfprefsd

# *only* if absent, add bundle id to make it show up in keyboard prefs pane
defaults read com.apple.universalaccess "com.apple.custommenu.apps"
defaults write com.apple.universalaccess "com.apple.custommenu.apps" -array-add "com.apple.finder"

$ defaults read com.apple.finder NSUserKeyEquivalents 
{
    "Add to Dock" = "";
    "Add to Sidebar" = "";
    "Show Package Contents" = "@$O";
}


来源:https://stackoverflow.com/questions/15719135/how-to-disable-keyboard-shortcuts-in-mac-os-x

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!