Recommendation for Sensors

Gesture sensor: Adafruit APDS9960 Proximity, Light, RGB, and Gesture Sensor [STEMMA QT / Qwiic] : ID 3595 : $7.50 : Adafruit Industries, Unique & fun DIY electronics and kits
Watch the video on that page, it shows how fun it is but also its limitations.

To hit something can be detected with a mechanical contact, an accelerometer or a piezo disc (knock sensor).
It depends on the device and how you want to hit it. I think that an accelerometer might be the best for this, but perhaps you have to start with something simple.