Difference between revisions of "Keyboard shortcuts"

m (Option 1: Edit the StartupMacros file: Mention case sensitivity)
(Use HTTPS links where feasible)
Line 19: Line 19:
== Creating your own keyboard shortcuts ==
== Creating your own keyboard shortcuts ==
You can also [http://imagej.net/docs/guide/146-31.html#toc-Subsection-31.2 assign your own keyboard shortcuts]!
You can also [https://imagej.net/docs/guide/146-31.html#toc-Subsection-31.2 assign your own keyboard shortcuts]!
== Assign a shortcut to a macro ==
== Assign a shortcut to a macro ==

Revision as of 11:54, 24 January 2020

ImageJ has a lot of keyboard shortcuts.

Listing all keyboard shortcuts

For a verbose list of keyboard shortcuts, call Plugins  › Shortcuts  › List Shortcuts.

The Command Launcher

Use ^ Ctrl+L (on Mac, Command+L) to open the Command Launcher, to call menu entries by name.

Recent Commands

To open a list of some recent commands, and a list of the most frequently called commands, hit ^ Ctrl+9 (on Mac, Command+9).


To open new images, type ^ Ctrl+O (on Mac, Command+O).

Creating your own keyboard shortcuts

You can also assign your own keyboard shortcuts!

Assign a shortcut to a macro

There are 3 options to assign a keyboard shortcut to a macro.

Option 1: Edit the StartupMacros file

Either put the code of the macro in the file macro>StartupMacros.ijm (or StartupMacros.fiji.ijm in Fiji) to have it installed automatically at startup.
The code of the macro must declare a keyboard shortcut in square bracket as such

macro "Macro 1 [1]" {
    print("The user pressed '1'");

macro "Macro 2 [h]" {
   print ("the user pressed 'h'");

macro "Macro 3 [H]"{
  print ("the user pressed 'shift + h'");

The key defined in square bracket is case sensitive ! If a capital letter is used then the shortcut is "shift + key".

For digit, the shortcut is functional with the row of digits at the top of the keyboard. It might not work with the keypad on the right.

Option 2: Save the macro(s) as a toolset

The shortcut should be defined in square bracket like for option 1, but instead of editing the existing StartupMacros file, the macros(s) can be saved as a separate MyShortcut.ijm or .txt file in the ImageJ/Fiji subfolder macros/toolsets.
Then restart ImageJ/Fiji and click the >> at the rightmost side of the fiji toolbar and click the entry MyShortcut. This will install your macros and thus activate the associated shortcuts.
This option is more convenient to distribute macros with keyboard shortcuts to colleagues or via an update site.

Option 3: Associate shortcut to a plugin menu entry

The second possibility consist in saving the macro code as a small script file into the ./Fiji.app/scripts/Plugins/ folder, so that it appears in the menu upon restart.
Then you can register a shortcut using Plugins › Shortcuts › Add Shortcut…