Maximum number of SN74HC165N

An example is in your code. You can handle the 74HC165 in almost the same way you handle the 74HC595.
With only little change, you can turn your writeRegisters() function into a readRegisters() function.

When you write to the 595, you control the clock and you set the data. So the data pin is an output pin.
When you read from the 165, you control the clock, but it sets the data that you then read. So the data pin is an input pin.

Here is another example:
https://playground.arduino.cc/Code/ShiftRegSN74HC165N
The read_shift_regs() function is where it happens. Note how it looks kind of similar to your writeRegisters() function. Except it uses a digitalRead() instead of digitalWrite() on the data pin.

There are some differences. Mainly, this example uses 1 bit per pin instead of 1 byte per pin; it stores the state of 16 buttons into one unsigned 16 bit int. (Where it says: "Set the corresponding bit in bytesVal".)

I believe you can just tie the /CE pin low.