The answer usually given is a 1919 game called Gun, which is often cited as the earliest example of a shooting game. It is, unsurprisingly, not something you can play — the hardware it was built for no longer exists in any working form.
Claims about "firsts" in this era are genuinely contested. Definitions matter a great deal: whether a mechanical arcade device counts, whether a light-gun cabinet counts, and whether an experiment on a university computer counts all produce different answers. The 1919 attribution is the one most commonly repeated, but the deeper you look the less settled it becomes.
If you want a playable ancestor of the genre, the light-gun arcade cabinets of the 1970s and early eighties are the practical starting point.