This is completely independant of the ‘normal’ method of flashing sketches to the board using the Arduino IDE. The Atmega8U2 chip on the Arduino UNO can be programmed directly using the special USB protocol called Device Firmware Update (DFU). All this is made possible by the use of the Arduino Device Firmware Update (DFU) function. The USB HID keyboard conforms to the standard USB specification, so is functional on all modern operating systems.
Make it a useful tool, with new buttons for Cut/Copy/Paste or Volume+/Volume-/Mute, or annoy your friends and colleagues by setting the keyboard to perform random keypress after random delays! Turn your Arduino UNO into a USB HID keyboard, and make buttons that do whatever you want.