Understand the concept of colours history - keyboard shortcut X

I need understand how the keyboard shortcut X → colour history (the last 5 colours) works and how I can describe it to an eventual feature in GIMP. Someone can help me to define in the development language this feature of MyPaint?

MyPaint's community forums is sponsored by Altispeed. Click here to visit their website.