Add a dedicated callback to duplicate the key for each type.
Keeping changes to the minimum necessary ones, the whole code and data
structure could use a serious update using C++ features, but this would
be totally out of scope of this fix.
Pull Request: https://projects.blender.org/blender/blender/pulls/134523