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?