Can't you reuse both static variables for both events and call `push_special_key` with `KE_EVENT` or `KE_CURSORHOLD`.  Perhaps like this:
```
int push_special_key(uint8_t event, uint8_t *buf, int maxlen)
{
   static const uint8_t event_key[3] = { K_SPECIAL, KS_EXTRA, KE_EVENT };
   static int key_idx = 0;
   
   event_key[2] = event;

   ... // here the old code
}
```
Or is this to messy?