How to connect a keyboard?

I have an Arduino Mega 2560 and want to use it to connect to a USB port and eventually to a keyboard. I have several different ones, with ranging complexity. There are some that require computer installed programs and others that just require a driver software. How do I install the driver software on the arduino and allow it to decode the ASCII presses? I know where I can find the USB port connector: https://www.mouser.com/ProductDetail/SparkFun/BOB-12700?qs=%2Fha2pyFadugS903J6RBRYQMELizFoPKOg6x2anpx%252baw%2FWGHaZLPBrL4JrbGTb9VkIgxWI5kFenA%3D but I don't know where I can find the library to decode it. I'm probably going to use a very simple keyboard because the other ones will probably need more memory. All I want is to just find a way to decode the USB signals. Thanks for reading, please answer with a library or a way to read the binary signals and hopefully take the bytes from the keyboard and turn them into a number, then decode with the ASCII decoding table (just put "(char)" in front of it).

A Mega can not be a USB host, only USB client. Can't do this directly.

I basically want to connect the keyboard to the arduino because I have an SD card on the SPI pins. If I can make more SPI pins, tell me how to do that.
I just need to find out how to connect the host to the arduino. Which pins does the host connect to?

SPI is a bus - MISO, MOSI and CLK pins are shared, you just have to have a separate CS/SS pin for each device.

Will they interfere if I do one command like "myFile=SD.open(directory);" and then something like "if(keyboard.keyPressed('a'))" with the file still open, will it interfere with the other SPI devices? Also, do I how do I change the SS pin? It doesn't say anything about KeyboardController.begin()

Also, do I need to have an IC that converts the USB signals to SPI language, or do I just need the four pins to connect? (Can I just buy this: https://www.mouser.com/ProductDetail/SparkFun/BOB-12700?qs=%2Fha2pyFadugS903J6RBRYQMELizFoPKOg6x2anpx%252baw%2FWGHaZLPBrL4JrbGTb9VkIgxWI5kFenA%3D) or do I need to buy this? (USB-SPI Adapters)

Arduino: 1.8.5 (Windows 7), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

Build options changed, rebuilding all
WARNING: library USBHost claims to run on (sam) architecture(s) and may be incompatible with your current board which runs on (avr) architecture(s).
In file included from C:\Users\Michele\Documents\Arduino\libraries\USBHost\src/KeyboardController.h:22:0,

from C:\Users\Pierre\Desktop\USB_TEST\USB_TEST.ino:1:

C:\Users\Michele\Documents\Arduino\libraries\USBHost\src/hidboot.h: In member function 'virtual void HIDBoot<BOOT_PROTOCOL>::EndpointXtract(uint32_t, uint32_t, uint32_t, uint32_t, const USB_ENDPOINT_DESCRIPTOR*)':

C:\Users\Michele\Documents\Arduino\libraries\USBHost\src/hidboot.h:474:62: error: 'UOTGHS_HSTPIPCFG_PTYPE_INTRPT' was not declared in this scope

pipe = UHD_Pipe_Alloc(bAddress, epInfo[index].deviceEpNum, UOTGHS_HSTPIPCFG_PTYPE_INTRPT, UOTGHS_HSTPIPCFG_PTOKEN_IN, epInfo[index].maxPktSize, 10, UOTGHS_HSTPIPCFG_PBK_1_BANK);

^

C:\Users\Michele\Documents\Arduino\libraries\USBHost\src/hidboot.h:474:93: error: 'UOTGHS_HSTPIPCFG_PTOKEN_IN' was not declared in this scope

pipe = UHD_Pipe_Alloc(bAddress, epInfo[index].deviceEpNum, UOTGHS_HSTPIPCFG_PTYPE_INTRPT, UOTGHS_HSTPIPCFG_PTOKEN_IN, epInfo[index].maxPktSize, 10, UOTGHS_HSTPIPCFG_PBK_1_BANK);

^

C:\Users\Michele\Documents\Arduino\libraries\USBHost\src/hidboot.h:474:151: error: 'UOTGHS_HSTPIPCFG_PBK_1_BANK' was not declared in this scope

pipe = UHD_Pipe_Alloc(bAddress, epInfo[index].deviceEpNum, UOTGHS_HSTPIPCFG_PTYPE_INTRPT, UOTGHS_HSTPIPCFG_PTOKEN_IN, epInfo[index].maxPktSize, 10, UOTGHS_HSTPIPCFG_PBK_1_BANK);

^

C:\Users\Michele\Documents\Arduino\libraries\USBHost\src/hidboot.h:474:178: warning: there are no arguments to 'UHD_Pipe_Alloc' that depend on a template parameter, so a declaration of 'UHD_Pipe_Alloc' must be available [-fpermissive]

pipe = UHD_Pipe_Alloc(bAddress, epInfo[index].deviceEpNum, UOTGHS_HSTPIPCFG_PTYPE_INTRPT, UOTGHS_HSTPIPCFG_PTOKEN_IN, epInfo[index].maxPktSize, 10, UOTGHS_HSTPIPCFG_PBK_1_BANK);

^

C:\Users\Michele\Documents\Arduino\libraries\USBHost\src/hidboot.h: In member function 'virtual uint32_t HIDBoot<BOOT_PROTOCOL>::Release()':

C:\Users\Michele\Documents\Arduino\libraries\USBHost\src/hidboot.h:500:54: warning: there are no arguments to 'UHD_Pipe_Free' that depend on a template parameter, so a declaration of 'UHD_Pipe_Free' must be available [-fpermissive]

UHD_Pipe_Free(epInfo[epInterruptInIndex].hostPipeNum);

^

C:\Users\Michele\Documents\Arduino\libraries\USBHost\src/hidboot.h: In instantiation of 'uint32_t HIDBoot<BOOT_PROTOCOL>::Release() [with unsigned char BOOT_PROTOCOL = 1u; uint32_t = long unsigned int]':

C:\Users\Pierre\Desktop\USB_TEST\USB_TEST.ino:14:1: required from here

C:\Users\Michele\Documents\Arduino\libraries\USBHost\src/hidboot.h:500:54: error: 'UHD_Pipe_Free' was not declared in this scope

C:\Users\Michele\Documents\Arduino\libraries\USBHost\src/hidboot.h: In instantiation of 'void HIDBoot<BOOT_PROTOCOL>::EndpointXtract(uint32_t, uint32_t, uint32_t, uint32_t, const USB_ENDPOINT_DESCRIPTOR*) [with unsigned char BOOT_PROTOCOL = 1u; uint32_t = long unsigned int]':

C:\Users\Pierre\Desktop\USB_TEST\USB_TEST.ino:14:1: required from here

C:\Users\Michele\Documents\Arduino\libraries\USBHost\src/hidboot.h:474:178: error: 'UHD_Pipe_Alloc' was not declared in this scope

pipe = UHD_Pipe_Alloc(bAddress, epInfo[index].deviceEpNum, UOTGHS_HSTPIPCFG_PTYPE_INTRPT, UOTGHS_HSTPIPCFG_PTOKEN_IN, epInfo[index].maxPktSize, 10, UOTGHS_HSTPIPCFG_PBK_1_BANK);

^

exit status 1
Error compiling for board Arduino/Genuino Mega or Mega 2560.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

I have this error when I tried to compile it, do I need to change the board to my UNO?

If you want to plug a USB keyboard into a mega, see the following library. And search youtube or google for "arduino usb host shield keyboard".

WARNING: library USBHost claims to run on (sam) architecture(s) and may be incompatible with your current board which runs on (avr) architecture(s).

The compile errors indicate you are using the wrong USB host software for the mega. It might be for Due (SAM) or something else. It will never work on mega.

I can't find out how to use it, it doesn't seem to want to connect to the arduino (Keyboards not responding to power). It's 3.3v but I can't seem to find a 3.3v keyboard, much less make the USB Host Shield work.