In calc, is there a way to trigger a series of events on a single key press?

I have an external switch, momentary closure on an external event, that could be a right click USB mouse button, or it could be a single keyboard keypress of a key I’d never use. Any existing switch on USB line that could be shunted by my external switch.

The results of this switch closure would be as follows:
Switch closure. Place current time into cell 1. Move right to next cell, 2.
Next switch closure to place current time in cell 2. Move right to next cell. Now calculate elapsed time between cell 1 &2, record in the current cell. Move to cell below cell 1. Wait for next switch closure. Repeat above until manually stopped by operator.

Hope you can offer a direction for me to follow. Thanks. Tom

I will not comment on closing a circuit with a hardware push-button or something of the kind. (There are barcode-scanners e.g. which send signals via USB as if something was typed in via the keyboard.)

To write a macro performing a series of steps, each one triggered by a repeatable event, and choosing the step depending on a reached state, is surely possible. How to do it using a software push-button (a form control) in a spreadsheet as the sender of the triggering signal is demonstrated in this attached example.

To use a specific key or a mouse action (not related to a control) for broadcasting the event that shall trigger the handling “macro” you need to register a respective listener. How to do so you may learn from the famous texts by Andrew Pitonyak: OpenOffice Macros Explained (“the book”) and Useful Macro Information.