You can try updating the software for the keyboard. HP should have the download for it...but, HP keyboards are notorious for not lasting very long. If you had this keyboard for more than a couple of years...then, swap it out with something else.random hp keyboard
The kind of problems you are seeing are typical of a multimedia keyboard (one with volume controls and such built in) dying. The reason it seems like someone is pressing the ESC key is because it IS being pressed (or at least the keyboard thinks it is). Basically the keyboard has developed an intermittent internal short...usually because the little pads have worn out and don't come up off the traces on the circuit board any longer, when you release a key.