Custom Keyboard Shortcuts: Difference between revisions

From kJams Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(11 intermediate revisions by the same user not shown)
Line 1: Line 1:
kJams allows you to customize almost all keyboard shortcuts.  To do this you create a special file named "'''Keyboard.txt'''" containing your modifications and you place it in the folder:
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:
<tt>/Users/(your user)/Library/Preferences/kJams/</tt>
<pre>
 
Mac: <home folder>/Library/Preferences/kJams/Keyboard.txt
Here is an example file:
Win: <home folder>/AppData/Roaming/Preferences/kJams/Keyboard.txt
# a comment line must begin with a pound sign (#), blank lines are ignored
</pre>
Instructions for editing the file are within the file itself.
# modifier keys are as follows
# a = apple key
# s = shift key
# o = option key
# c = control key
# they may come in any order, eg: "asoc" is the same as "oacs"
# they must be followed by a dash character, eg: -
# followed by the UNMODIFIED version of the key you want to use
# ie: if you want shift-S then specify "s-s", not "s-S"
# ergo: you can not use keys which require shifting, controlling, or optioning
# eg: the @ sign is not legal (shift 2 on US keyboards), but you can use "s-2"
# lines must end with a semi-colon: ;
"Menu/Controls/Pitch Down" = "a-t";
"Menu/Controls/Pitch Up" = "a-y";
"Menu/Controls/Original Pitch" = "a-u";
"Menu/Controls/Tempo Slower" = "as-t";
"Menu/Controls/Tempo Faster" = "as-y";
"Menu/Controls/Original Tempo" = "as-u";
To download this file, [http://www.kjams.com/downloads/Keyboard.txt click here].


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:
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:


# In the Finder, context-click (which means control- or right- click) on the kJams application icon, and pick "Show Package Contents"
# find the file:
## Mac: In the Finder, [[Context Click]] on the kJams application icon, and pick "Show Package Contents".
## Windows: just open the "kJams.app" folder
# Inside that folder, navigate to this file:<pre>Contents/Resources/English.lproj/Menus.strings</pre>
# Inside that folder, navigate to this file:<pre>Contents/Resources/English.lproj/Menus.strings</pre>
# Copy the '''Menus.strings''' file to the desktop
# Copy the '''Menus.strings''' file to the desktop
# Rename it so it says '''Menus.txt''' (it is after all just a text file)
# Rename it so it says '''Menus.txt''' (it is after all just a text file)
# double click it --> TextEdit should now launch
# double click it --> TextEdit should now launch
# before you do anything, go to TextEdit->Preferences, and under "Format" pick "Plain Text", this is important
# Mac: before you do anything, go to TextEdit->Preferences, and under "Format" pick "Plain Text", this is important
# Now make a new text document, save it, call it "'''Keyboard.txt'''"
# Now open the file mentioned above, "'''Keyboard.txt'''"
# Now find the lines in the Menus.txt file that you want to add keyboard shortcuts for, eg: find the line<pre>"Menu/Controls/Original Pitch" = "Original Pitch";</pre>
# 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<pre>"Menu/Controls/Original Pitch" = "Original Pitch";</pre>
# Now type that line into "'''Keyboard.txt'''".  DO NOT COPY AND PASTE.  The original document is encoded in UTF16, while your document MUST BE encoded in MacRoman.  If you don't know what this means then you must type.  If you have the ability to convert between UTF18 and MacRoman then go ahead (only XCode seems to do this properly.  TextWrangler seems to have the ability but it does NOT work)
# 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))
# Now in your new document, delete all the text inside the quotes on the right hand side of the equals sign (=) (don't delete the quotes!)
# 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")
# Type something like a-y (this stands for ⌘-Y, "a" for "apple"), save
# Place that file in the correct location (see top of this page)
# Place that file in the correct location (see top of this page)
# run kJams.
# run kJams.


You should now have custom a keyboard shortcut for that item.
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 [http://msdn.microsoft.com/en-us/library/dd375731%28v=VS.85%29.aspx documented here]


There are some exceptions currently, which I'll remove if people complain:
==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.
<pre>
<pre>
kMenuItemID_FILE_SHOW_ORIGINAL must have shift
/* For use with Get/SetMenuItemKeyGlyph*/
kMenuItemID_FILE_PAGE_SETUP must have shift
enum {
kMenuItemID_EDIT_REDO must have shift
  kMenuNullGlyph                = 0x00, /* Null (always glyph 1)*/
kMenuItemID_EDIT_CLEAR can not have command, glyph is backward delete
  kMenuTabRightGlyph            = 0x02, /* Tab to the right key (for left-to-right script systems)*/
kMenuItemID_EDIT_DESELECT_ALL must have shift
  kMenuTabLeftGlyph            = 0x03, /* Tab to the left key (for right-to-left script systems)*/
kMenuItemID_EDIT_FIND_IN_LIBRARY must have shift
  kMenuEnterGlyph              = 0x04, /* Enter key*/
kMenuItemID_CONTROLS_PLAY can not have command
  kMenuShiftGlyph              = 0x05, /* Shift key*/
kMenuItemID_CONTROLS_NEXT_SONG can not have command, glyph is right arrow
  kMenuControlGlyph            = 0x06, /* Control key*/
kMenuItemID_CONTROLS_PREV_SONG can not have command, glyph is left arrow
  kMenuOptionGlyph              = 0x07, /* Option key*/
kMenuItemID_CONTROLS_VOL_UP glyph is up arrow
  kMenuSpaceGlyph              = 0x09, /* Space (always glyph 3) key*/
kMenuItemID_CONTROLS_VOL_DOWN glyph is down arrow
  kMenuDeleteRightGlyph        = 0x0A, /* Delete to the right key (for right-to-left script systems)*/
kMenuItemID_CONTROLS_MUTE glyph is down arrow, ??must have option??
  kMenuReturnGlyph              = 0x0B, /* Return key (for left-to-right script systems)*/
kMenuItemID_CONTROLS_KILL_LEFT_CHANNEL must have option
  kMenuReturnR2LGlyph          = 0x0C, /* Return key (for right-to-left script systems)*/
kMenuItemID_CONTROLS_KILL_RIGHT_CHANNEL must have option
  kMenuNonmarkingReturnGlyph    = 0x0D, /* Nonmarking return key*/
kMenuItemID_CONTROLS_KILL_CENTER_CHANNEL must have option
  kMenuPencilGlyph              = 0x0F, /* Pencil key*/
all graphic channels can not have command, must have control
  kMenuDownwardArrowDashedGlyph = 0x10, /* Downward dashed arrow key*/
graphic channels above 9 same as above, plus must have shift
  kMenuCommandGlyph            = 0x11, /* Command key*/
kMenuItemID_CONTROLS_TEMPO_UP must have shift
  kMenuCheckmarkGlyph          = 0x12, /* Checkmark key*/
kMenuItemID_CONTROLS_TEMPO_DOWN must have shift
  kMenuDiamondGlyph            = 0x13, /* Diamond key*/
kMenuItemID_CONTROLS_TEMPO_NORMAL must have shift
  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)*/
};
</pre>
</pre>

Latest revision as of 21:36, 12 September 2018

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)*/
};