How is the engine able to access input in the processInput() function (for example a key press), if the key is both pressed and released very quickly while the program is executing a different function. By the time processInput() executes on the next cycle, it seems to me like the program would be "unaware" that this input ever happened.
Back in the day, like on Commodore C>64s or the TRS-80, the keyboard was a bunch of memory-mapped switches and to get keypresses without going through the operating system you had to grab that memory and figure out which keys were currently pressed.
On PCs, however, the keyboard is an actual I/O device. You press a key, the keyboard hardware debounces it, and queues up a "make" message. You release the key and the keyboard queues up a "break" message. Neither the operating system nor the processor is involved with detecting physical key presses or releases, and there isn't really any way that you could possibly hit and release a key so quickly that the device misses it.
Just from intuition (and I could be very wrong here), I'm guessing that things like keyboard input force a hardware interrupt, store the key value into some kind of device specific storage buffer queue, and then can be accessed and flushed at the correct time (next processInput() call) by a program?
The quick answer is that modern USB and Bluetooth keyboards are polled, and the keyboard driver handles the message packets from the keyboard which are then made available to the operating system. Your programming language generally translates the keyboard data and puts it into a queue for easy "get next key" type usage, but you can bypass your programming language's input(), inkey(), readkey(), or get_char() statements and, instead, go through the operating system to interact with the driver more directly in order to get raw, or at least less-cooked, information.
If this is true, how does the engine handle stuff like multiple key presses. If I had a buffer queue that looked something like...
I'm extemporizing a bit here, but the engine will get the make and break codes from the operating system's keyboard driver and will make a map of keys so that you can query the engine in the form of something like key.ispressed(KEYW + KEYSPACE + KEYC) to determine whether a particular key combination is currently being held down.
You indicated that your program would get a string of ws, for example, because the w key is being held down, but this isn't how it would work. If the engine were using a call like getkey() or something like that then yes, you'd get a buffered string of repeated ws when that key is held down, but that's why the engine wouldn't do it that way. The engine would get the raw make and break codes and manage the keyboard map itself.
DMGregory's suggestion to take a look at the keyboard functions from a few game engine APIs is a good one.