Try this first: Disconnect all peripherals (ie., mouse, keyboard, printer, etc.), unplug your A/C wire from the power supply, hold down your power button for ~10 seconds, then reconnect everything (make sure the mouse/keyboard are not in any USB 3.0 ports), boot back up and see if any functionality has been restored to the mouse/keyboard. If not, move on to the following:
Did your computer come with Windows 8 pre-installed? If the answer is yes, check to see if you have the following set of options in BIOS:
Immediately after pushing the power button, repeatedly push the Escape key until you get the Startup menu, then go to Computer Setup (or press F10).
1. Security Menu
2. Secure Boot Configuration
3. Press F10 to continue at the warning screen
4A. Legacy Support option > If it is already 'disabled', set to 'enable' and then set the Secure Boot option underneath it to 'disable'
OR
4B. If the Legacy Support option is already set to 'enable', set it to 'disable' and then set the Secure Boot option underneath it to 'enable'
5. Disable Fastboot option
6. Press F10 to Accept your changes, then Save and restart
Make sure you remember these settings so you can revert back to whatever they were should they cause any problems with booting the OS,
or, if the above does not work, set them back to the pre-existing configuration (which was probably Legacy mode disabled, and Secure Boot enabled).
If you do not have these options, and the computer came shipped with Windows 7 (or anything pre-Windows 8), go to HP Support, download and install the latest BIOS for your machine -
Here is the link and instructions :
HP Consumer Desktop PC BIOS Update (ROM Family 2ADA) - HP Pavilion 500-023w Desktop PC | HP® Support
Other things you can try: Does the computer have PS/2 ports? If it does, try a USB>PS/2 adaptor for your mouse/keyboard. You can also try a wireless mouse/keyboard...you can plug in a wireless USB receiver at the login screen...