Action to simulate holding down a button

Is there a way in HA to simulate holding down a button on a physical remote control for some number seconds?
On my ROKU TV, sometimes I need to sign into certain apps, the usually instruct you to hold down the play/pause button for 5 to 10 seconds to get an activation code that you then use to activate the app.

By the way when I hold the physical remote down I can see the lights on the ROKU receiver flashing continuously (very fast)

I’ve tried this w/o success:

simulate_press_play_pause:
    sequence:
      repeat:
        count: 50
        sequence:
          - service: remote.send_command
            data:
              command: play
              entity_id: remote.32_tcl_roku_tv
          - delay:
              milliseconds: 100

When I run this, I see see the TV play/pause but the code does not show up. If I get the physical remote and hold down the play/pause button for like 8 secs the code appears

Well 50 x 100msec is only 5 seconds, not 8.

Also Home assistant does not time sub 1 second delays well. There is no guarantee of 100ms, it’s not an RTOS.