2 of 2 people found this helpful
There may be several ways to achieve what you want, but more info would be needed (e.g. for your use-case, can the Pi be dedicated to running just one application that waits for a keypress to execute the Python script).
Otherwise, this might help (I've not tried it, but they give an example where a keyboard combination will run a browser, so the principle is similar):
What should be known is if the keyboard event(s) should be intercepted always of only when some kind of application are running. This determine how depth the key-catching should be done. But in general under Linux it is possible to att with few lines of code a background process enabled by certain keys sequences.