Here's an implementation of the game you described as a single HTML file:
Save the above code as an HTML file, open it in a web browser, and you'll be able to play the fighting game using the described controls. The game is displayed using a canvas element, and the blue square represents the player while the red square represents the enemy. The player and enemy both have health bars, and the game loop constantly updates their positions, checks for collisions and controls user inputs to perform specific actions.