custom keyboard shortcuts for own options?

Hi, is it possible to assign a custom key to each of the options you add in your own recipe? E.g., I have the following code to add my options, but I would like to assign the key p to option positiveetc. Currently, they are assigned to the keys 1, 2etc.

def add_options(stream):
    """Helper function to add options to every task in a stream."""
    options = [{'id': 'positive', 'text': '😊 positive'},
               {'id': 'neutral', 'text': '😶 neutral'},
               {'id': 'negative', 'text': '🙁 negative'},
               {'id': 'posneg', 'text': '😊+🙁 pos+neg.'}]
    for task in stream:
        task['options'] = options
        yield task

Yes, this is something that I've wanted for a while – but the current implementation of the shortcuts made it difficult to allow changing them at runtime (which is why they're currently hardcoded). But I want to give it a shot again and maybe refactor this part, so users can pass in custom keymaps via the recipe config or their prodigy.json. So you could then do something like this:

# Disclaimer: this is a proposal and currently doesn't work
"config": {
    "keymap": {
        "accept": ["1", "a"],
        "reject": ["2", "x"],
        "save": ['command+space'],
        "choice": ["p", "n", "m"]
    }
}

If I remember correctly, the choice options are currently selected by index (hence the numbers), so in order to make this work, the options might need to specify an additonal key, like "key": "p".

That would be awesome! Or, alternatively, one idea might be to allow users to add the shortcut keys programmatically, e.g., in the add_options function.

1 Like