Custom keyboard shortcuts for labels not working


I've updated to 1.9.4 to try custom key mappings:

I have a manual choice task with an options field like this:

[{'id':'first','text':'First Option'},{'id':'second','text':'Second Option'},...]

I'd added to prodigy.json a keymap_by_label field like this:

{"first": "f", "second": "s"}

But in the web interface the new mappings are ignored and I just see the default 1-n values. How I done something wrong?

Edit: The forum mangled my URL above. Add an anchor #actions-custom-labels to the end to get to the right section.

Hi! Sorry if this was confusing – the options currently use the numbers "1", "2", "3" and so on to describe the options in order (not the IDs on the individual options). This makes it easier to have one general-purpose setting, e.g. if you want to always map them to a fixed sequence of keys like QUERTY.

So in your case, your label keymap would have to look like this: {"1": "f", "2": "s"}.

1 Like

Thanks! Got it working now.

Further, can I request custom key mappings at the task level, so I can apply them in my custom recipes? It would really speed up some of my common workflows, especially those with >10 options. For example, they could live in the options field, like this:

[{'id':'first','text':'First Option','key':'f'},{'id':'second','text':'Second Option','key':'s'},...]

Instead of the prodigy.json, you can also use the "config" returned by your recipe. For example:

# your recipe code etc.
return {
    "dataset": dataset,
    "stream": stream,
    "view_id": "text",
    "config": {"keymap_by_label": your_keymap}

You could even generate the keymap automatically in Python – e.g. use the first letter of the option ID if available. Or you could accept a command line argument that sets the shortcuts.

1 Like

Yes! That's what I was wanting. I've tried it and it's working fine, thanks. I hadn't appreciated you could override global settings in with the recipe config field.