2009 iMac with ? at boot screen

A few years ago I formatted my 2009 iMac incorrectly. I think I used APFS instead of MacOS extended. When I rebooted the iMac I got the dreaded ? On the screen. I had only an Apple Bluetooth keyboard and mouse so I bought a wired Windows keyboard and mouse hoping to press all the combinations to get the iMac to boot properly. Does anyone have any suggestions? I figure taking it to a shop would be more expensive than what it is worth.
I have a MacBook Pro M1, so the iMac would only be used to watch movies on in the background

Normally Command R on bootup will get you into recovery mode, and you should be able to repair or reformat the disk from there. Then install macOS.

How to repair a Mac disk with Disk Utility – Apple Support (UK)