Custom Keyboard Shortcuts

From kJams Wiki
Jump to navigation Jump to search

kJams allows you to customize all keyboard shortcuts. To do this you edit a special file named "Keyboard.txt" which resides in your preferences folder at this location:

Mac: <home folder>/Library/Preferences/kJams/Keyboard.txt
Win: <home folder>/AppData/Roaming/Preferences/kJams/Keyboard.txt

Instructions for editing the file are within the file itself.

You'll notice how each line begins with the quoted string that is the path to the menu item. These strings come directly from the strings file located inside the kJams application bundle. To get to that file, follow these steps:

  1. find the file:
    1. Mac: In the Finder, Context Click on the kJams application icon, and pick "Show Package Contents".
    2. Windows: just open the "kJams.app" folder
  2. Inside that folder, navigate to this file:
    Contents/Resources/English.lproj/Menus.strings
  3. Copy the Menus.strings file to the desktop
  4. Rename it so it says Menus.txt (it is after all just a text file)
  5. double click it --> TextEdit should now launch
  6. Mac: before you do anything, go to TextEdit->Preferences, and under "Format" pick "Plain Text", this is important
  7. Now open the file mentioned above, "Keyboard.txt"
  8. Now find the lines in the Menus.txt file that has the text of the command that you want to add keyboard shortcuts for, eg: if you search for "original pitch", you will find the line
    "Menu/Controls/Original Pitch" = "Original Pitch";
  9. Now search in "Keyboard.txt" for that same thing. If you do not find it you must TYPE it. DO NOT COPY AND PASTE. (The original document is encoded in UTF16, while your document MUST BE encoded in MacRoman (mac) or WindowsLatin1 (windows). If you don't know what this means then you must type. If you have the ability to convert between UTF18 and your platform encoding, then go ahead (on the mac only XCode seems to do this properly. TextWrangler seems to have the ability but it does NOT work))
  10. Now on the right hand side of the equals sign, type something like a-y (this stands for ⌘-Y, "a" for "apple"), save (windows "c-y" for "Control+Y")
  11. Place that file in the correct location (see top of this page)
  12. run kJams.

You should now have custom a keyboard shortcut for that item.

Limitations

  • don't move the space bar (kMenuSpaceGlyph) to any other command but Play, it will always invoke the Play command. However, you can *remove* it if you want, so space bar will NOT play.
  • the "Clear" command: holding the Command key (⌘) will always skip the confirmation dialogs (answering yes), and holding the Shift key (⇧) will always delete the original files

Windows: Hard to get Keys

You can use virtual key codes documented here

Mac: Hard to get Keys

There are some glyphs that are hard to type on the keyboard, for these you can use the codes below. Find the key you want, say the left arrow key, and look for it's code, which is 0x64, and type that for it's key. The file has many examples to show you how to do it.

/* For use with Get/SetMenuItemKeyGlyph*/
enum {
  kMenuNullGlyph                = 0x00, /* Null (always glyph 1)*/
  kMenuTabRightGlyph            = 0x02, /* Tab to the right key (for left-to-right script systems)*/
  kMenuTabLeftGlyph             = 0x03, /* Tab to the left key (for right-to-left script systems)*/
  kMenuEnterGlyph               = 0x04, /* Enter key*/
  kMenuShiftGlyph               = 0x05, /* Shift key*/
  kMenuControlGlyph             = 0x06, /* Control key*/
  kMenuOptionGlyph              = 0x07, /* Option key*/
  kMenuSpaceGlyph               = 0x09, /* Space (always glyph 3) key*/
  kMenuDeleteRightGlyph         = 0x0A, /* Delete to the right key (for right-to-left script systems)*/
  kMenuReturnGlyph              = 0x0B, /* Return key (for left-to-right script systems)*/
  kMenuReturnR2LGlyph           = 0x0C, /* Return key (for right-to-left script systems)*/
  kMenuNonmarkingReturnGlyph    = 0x0D, /* Nonmarking return key*/
  kMenuPencilGlyph              = 0x0F, /* Pencil key*/
  kMenuDownwardArrowDashedGlyph = 0x10, /* Downward dashed arrow key*/
  kMenuCommandGlyph             = 0x11, /* Command key*/
  kMenuCheckmarkGlyph           = 0x12, /* Checkmark key*/
  kMenuDiamondGlyph             = 0x13, /* Diamond key*/
  kMenuAppleLogoFilledGlyph     = 0x14, /* Apple logo key (filled)*/
  kMenuParagraphKoreanGlyph     = 0x15, /* Unassigned (paragraph in Korean)*/
  kMenuDeleteLeftGlyph          = 0x17, /* Delete to the left key (for left-to-right script systems)*/
  kMenuLeftArrowDashedGlyph     = 0x18, /* Leftward dashed arrow key*/
  kMenuUpArrowDashedGlyph       = 0x19, /* Upward dashed arrow key*/
  kMenuRightArrowDashedGlyph    = 0x1A, /* Rightward dashed arrow key*/
  kMenuEscapeGlyph              = 0x1B, /* Escape key*/
  kMenuClearGlyph               = 0x1C, /* Clear key*/
  kMenuLeftDoubleQuotesJapaneseGlyph = 0x1D, /* Unassigned (left double quotes in Japanese)*/
  kMenuRightDoubleQuotesJapaneseGlyph = 0x1E, /* Unassigned (right double quotes in Japanese)*/
  kMenuTrademarkJapaneseGlyph   = 0x1F, /* Unassigned (trademark in Japanese)*/
  kMenuBlankGlyph               = 0x61, /* Blank key*/
  kMenuPageUpGlyph              = 0x62, /* Page up key*/
  kMenuCapsLockGlyph            = 0x63, /* Caps lock key*/
  kMenuLeftArrowGlyph           = 0x64, /* Left arrow key*/
  kMenuRightArrowGlyph          = 0x65, /* Right arrow key*/
  kMenuNorthwestArrowGlyph      = 0x66, /* Northwest arrow key*/
  kMenuHelpGlyph                = 0x67, /* Help key*/
  kMenuUpArrowGlyph             = 0x68, /* Up arrow key*/
  kMenuSoutheastArrowGlyph      = 0x69, /* Southeast arrow key*/
  kMenuDownArrowGlyph           = 0x6A, /* Down arrow key*/
  kMenuPageDownGlyph            = 0x6B, /* Page down key*/
  kMenuAppleLogoOutlineGlyph    = 0x6C, /* Apple logo key (outline)*/
  kMenuContextualMenuGlyph      = 0x6D, /* Contextual menu key*/
  kMenuPowerGlyph               = 0x6E, /* Power key*/
  kMenuF1Glyph                  = 0x6F, /* F1 key*/
  kMenuF2Glyph                  = 0x70, /* F2 key*/
  kMenuF3Glyph                  = 0x71, /* F3 key*/
  kMenuF4Glyph                  = 0x72, /* F4 key*/
  kMenuF5Glyph                  = 0x73, /* F5 key*/
  kMenuF6Glyph                  = 0x74, /* F6 key*/
  kMenuF7Glyph                  = 0x75, /* F7 key*/
  kMenuF8Glyph                  = 0x76, /* F8 key*/
  kMenuF9Glyph                  = 0x77, /* F9 key*/
  kMenuF10Glyph                 = 0x78, /* F10 key*/
  kMenuF11Glyph                 = 0x79, /* F11 key*/
  kMenuF12Glyph                 = 0x7A, /* F12 key*/
  kMenuF13Glyph                 = 0x87, /* F13 key*/
  kMenuF14Glyph                 = 0x88, /* F14 key*/
  kMenuF15Glyph                 = 0x89, /* F15 key*/
  kMenuControlISOGlyph          = 0x8A, /* Control key (ISO standard)*/
  kMenuEjectGlyph               = 0x8C, /* Eject key (available on Mac OS X 10.2 and later)*/
  kMenuEisuGlyph                = 0x8D, /* Japanese eisu key (available in Mac OS X 10.4 and later)*/
  kMenuKanaGlyph                = 0x8E  /* Japanese kana key (available in Mac OS X 10.4 and later)*/
};