I don’t know if I can connect a usb keyboard to an arduino without an USB Host Shield.
I am thinking, maybe I can get a female USB cable, plug the keyboard in and read the wires. As far as I know, a USB cable contains two power and two data lines. Is it possible to just read the data cables and decode the result into ASCII? If yes, would that be working via HID codes?
Would I be able to use for example this sheet of codes, or would I have to find out the codes by myself?
Thank you for your help in advance
No, use an old PS2 keyboard instead. There is a library to support that connection.
It depends on the Arduino and the USB keyboard.
Many, but not all, USB keyboards have the ability to also work as a PS/2 keyboard. If your keyboard has this PS/2 capability, then you can connect it directly to any Arduino board and use one of the PS/2 Arduino libraries to read the keypresses (and, with some of the libraries, even control the lights on the keyboard). If the keyboard comes with a USB to PS/2 adapter, then it has this capability. Keyboards that don't come with the adapter may also work, or not. I tested a high end mechanical keyboard, a high end mechanical numeric keypad, a cheapo HP keyboard, and a cheapo off-brand keyboard and all 4 worked, but my super cheap numeric keypad did not.
You can find more information about connecting PS/2 keyboards to an Arduino board here:
You don't need a PS/2 adapter for the USB keyboard. You can just cut the USB cable and connect the wires directly to your Arduino. The connections:
Red (Vcc) - 5V
White (Data-) - Data
Green (Data+) - Clock/IRQ
Black (Ground) - GND
Some of the more advanced Arduino boards have USB host capability, and thus are able to directly communicate with USB devices.