I'm making screencasts (like the ones on Khan Academy) with GIMP as a virtual blackboard.

Right now, switching foreground colors is a bit of a hassle--I have to move my pen over to the palette in my toolbox, click on a color, then move my pen back over to the image window. This takes time, especially when switching colors rapidly.

How can I assign keyboard shortcuts to colors in my palette, so I can access them easier?

5 Answers 5


In my case (which brought me to your question) D for resetting and X for swapping colors is sufficient. Combined with O you can maybe set up some nice workarounds.

Default Colors

By default, GIMP sets the foreground color to black and the background color to white and it can be surprising how often you want to use these two colors. To reset these colors quickly, just press the D key. Also you can easily swap the foreground and background colors by pressing the X key.

Source: http://graphicssoft.about.com/od/gimptutorials/a/useful-keyboard-shortcuts.htm

  • Thanks for replying! I've resorted to using AutoHotkey to map my function keys to click coordinates on-screen then refocus the canvas when in GIMP. It's not very flexible, though, since I have to make sure the windows are in the same spot every time I start up my blackboard. Commented Aug 26, 2014 at 21:33

I know this is an old question, but there's a much better answer now in recent versions of GIMP.

Use a palette.

Under Edit > Keyboard Shortcuts > Context there are a few useful shortcuts:

  • Foreground: Use Previous Palette Color
  • Foreground: Use Next Palette Color
  • Foreground: Use First Palette Color
  • Foreground: Use Last Palette Color

There are other options for setting the foreground color based on a palette or based on other color sources, and there are equivalent shortcuts for the background color as well.

An example use-case follows.

  • I mapped Foreground: Use Next Color to # (Shift + 3).
  • I mapped Foreground: Use Previous Palette Color to @ (Shift + 2).
  • Under Windows > Dockable Dialogs > Palettes, I created a new palette.
  • Under Dockable Dialogs > Palette Editor, I gave my palette a name.
  • For each color I wished to use, I changed my foreground to that color, then in the Palette Editor I clicked Create new entry from the foreground color.

As I edited, I used @ and # to quickly switch between colors.


As far as I know, no such functionality exists in GIMP. As you probably already know, GIMP was neither designed for art nor screencasting, and, as such, would have little need for such a feature.

However, assuming that you don't need to see the entire screen (your screen recorder just uses the part of GIMP that is the canvas), you could set up several colors using the Pencil or Paintbrush tool outside the visible area to create an actual virtual "palette." It would then be as simple as pressing the O key to get the eyedropper tool, then clicking on one of the colors you put out.

  • Thank you for the reply. O is indeed a very useful shortcut! In my case, however, my screen recorder (OBS) is most easily set up to record an entire window, which would be my shrink-wrapped, 1024x768 canvas. Commented Aug 26, 2014 at 21:32

I wanted something similar so I've written a short script. This is my first effort with a lisp like language so I'm sure the example below could be improved, but it works for me on gimp 2.8.

;; script-fu to cycle between a set of foreground colours
;; edit the variable colours to modify the set
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License.

(define (script-fu-cycle-foreground-colour)

 ;add to or edit the list of colours to cycle here:   
 (define colours (list '(255 255 255) '(255 0 0) '(0 255 0) '(0 0 255) '(100 100 100)))

 (define list-index
  (lambda (e lst)
  (if (null? lst)
   (if (equal? (car lst) e)
     (if (= (list-index e (cdr lst)) -1)
      (+ 1 (list-index e (cdr lst)))

 (gimp-context-set-foreground (list-ref colours (modulo (+ 1 (list-index (car (gimp-context-get-foreground)) colours)) (length colours))))


(script-fu-register "script-fu-cycle-foreground-colour"
         _"<Image>/Colors/Cycle FG"
         _"Cycles foreground colour"
         "Jan Marchant"
         "Jan Marchant"
         "January 2015"

If you just want to assign individual shortcuts for specific colours, I guess something really simple like this would work (not tested):

;; script-fu to cycle between foreground colours
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License.

(define (script-fu-foreground-red)

 (gimp-context-set-foreground '(255 0 0))


(script-fu-register "script-fu-foreground-red"
         _"Sets foreground to red"
         "Jan Marchant"
         "Jan Marchant"
         "January 2015"

For Linux save your finished scripts in your $HOME/gimp-x.y/scripts directory edit: you must use the extension .scm (similar for other OSes I guess) and then navigate to "Filters - Script-Fu - Refresh Scripts" in gimp. You should find new menu items "Colors - Cycle FG" and "Colors - Foreground - Red", and you can assign keyboard shortcuts to them (under plug-ins but easiest if you use the search box).

Of course you can extend to as many colours as you like.

Cheers, Jan


The scheme solution is really slow when using 15+ colors, so I created this python script to cycle through a list of 20+ colors, and it does so much quicker.

#!/usr/bin/env python

# this plug-in would normally be installed in the GIMP 2\lib\gimp\2.0\plug-ins folder 
# you may need to restart GIMP for this plug-in to appear in the Colors menu
# this has been tested on Windows with Gimp 2.8.14
from gimpfu import *

def color_cycle() :
    #this code sends a message back to Gimp communicating status
    pdb.gimp_message('Attempting to set the foreground color...')

    #you can change the colors in this list to suit your needs, but every color should be unique
    colors = [(0, 0, 0), 
              (236, 236, 236), 
              (110, 110, 110), 
              (87, 87, 87), 
              (41, 28, 19),
              (255, 255, 35),
              (216, 216, 1),
              (1, 216, 6),
              (0, 119, 3),
              (0, 44, 1),
              (86, 160, 211),
              (2, 41, 255),
              (1, 22, 142),
              (0, 13, 81),
              (38, 0, 58),
              (125, 1, 188),
              (255, 192, 203),
              (255, 129, 213),
              (223, 1, 41),
              (134, 1, 25),
              (42, 0, 8),
              (224, 97, 2)

    #backup the background color
    bg = gimp.get_background()

    i = 0
    bFound = False

    while (bFound == False):
        #using background to compare helps with floating point precision problems
        if (gimp.get_foreground() == gimp.get_background()):
            bFound = True
            i += 1
            i += 1
            if (i > (len(colors) - 1)):
                i = 0
                bFound = True

    if i > len(colors) - 1:
        i = 0

    #if current color found in colors, then return the next one, otherwise return the first one
    color = colors[i]
    #restore the backed-up background color
    pdb.gimp_message('Done setting the foreground color...')

    "Color Cycling",
    "Cycle the foreground through a list of colors.",
    "David Zahn",
    "David Zahn",
    "Color Cycle ForeGround",
    "*",      # Alternately use RGB, RGB*, GRAY*, INDEXED etc.
    color_cycle, menu="<Image>/Colors")


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .