8 chnl cap. touch + shift in (CD4021) + arduino nano+ shift out (74hc595)

Experienced electronics tech here... trying to build something. As the title describes, I have the sainsmart ttp226 8 channel capacitive touch board and I want to send its 8 channels into a shift in CD4021, make each button latch (push on push off) and sent to the 74hc595, shifted out to an 8 channel optocoupled relay board.
Basically, I want to make a capacitive touch relay controller.

I have all the components and have them all working individually, the shift in- shifts in, relay board clicks, capacitive touch lights up (extremely sensitive), and the 595 shifts out. My problem is I dont know how to make them all work together, in the code that is. I know how to connect everything, and I understand how each sends in and out its data... but I dont know what to do about making it all work together.
How do I take the shift in data and send it to the shift out? (can the 595 and cd4021 share clock? latch?)
How do I make the capacitive buttons into a latched, push on/push off style?

I dont need a crazy fast read rate of the button presses, this will be controlling lights and they will likely be on for a while.

I have all the example code for each item and they all work, I just dont know how to make them all work together.

Thanks for any help!

Oh, and I have an Uno for prototyping and will be finalizing with a nano

I have a page about the 595 and one about the 165 which is an input shift register which is probably similar to the CD4021.

You can drive both via SPI which is implemented in hardware on the Uno, you would need separate slave select lines for each chip.

As for making them work together, it's hard to say without seeing your code. I suggest you take a stab at it. Personally I would be reading the sensor, and depending on what I read, send things to the 595.

The sensor came with 8 pins out and not set up for serial out... thus the whole basis for shifting in and shifting out.

I just looked up the IC on the capacitive touch, and it has a serial out capability.... but I would almost have to build a new board for it. I suppose for now, I'll try to figure out shift in and shift out. Later, I will look into building a board and trying the serial side.

Thank you for your help, I will start looking into the SPI and how that works.

So I tried to give the SPI a shot, but I just didn't understand (or didn't want to figure out) the translation of pins from the exampled 74hc165 to the CD4021BE. I decided to go with what I could understand. I got it working, with some strange side effects. I wont outline them here, because its rudimentary crap of replacing cheap chips and adding pull downs on the inputs.
Even though I didn't make a solid attempt at the SPI, I still had to translate others examples of the 74HC165 to figure out which pins did what and how to use the the serial data.

The only problem I cant seem to solve is when I press input 7, both 7 and 8 light up. The serial display shows that they are both pressed, but there is no voltage leaving 8's pin and nothing into 8's input on the CD4021BE. I tried multiple things to solve it; editing delays, changing from LSB to MSB, adding resistance, disconnecting 8's lead from the IC completely... still the same result. I changed the IC 4 times, surely I didnt get 5 identically failed ICs.
And sometimes, the input (CD4021BE) seems unstable and gets all out of whack and begins spitting out erroneous serial states. Like pin one would show in the serial display that it was being pressed about 4 times a second, but there was no input to it. And pin 8 coming out of the 74HC595 was blinking the led at the speed of the latch pin. I tried removing the serial monitor to see if that helped, and it did not. Finally changing to another 595 has appeared to solve the issue.

Heres the code

// 74HC595 CD4021BE
// Pin 1 - relay 1 Pin 1 - input 7
// Pin 2 - relay 2 Pin 2 - NC Q6 (pulse behind q7)
// Pin 3 - relay 3 Pin 3 - Q8 data pin
// Pin 4 - relay 4 Pin 4 - input 3
// Pin 5 - relay 5 Pin 5 - input 2
// Pin 6 - relay 6 Pin 6 - input 1
// Pin 7 - relay 7 Pin 7 - input 0
// Pin 8 - Negative (Ground) Pin 8 - Negative (Ground)
// Pin 9 - (Not Used) Serial out Pin 9 - pl latch pin
// Pin 10 - MR Master Reset (+) Pin 10 - cp clock pulse
// Pin 11 - SHCP CLOCK Pin 11 - ds? serial data input (not used)
// Pin 12 - STCP LATCH Pin 12 - Q7 pulsebehind q8
// Pin 13 - OE Output Enable (-) Pin 13 - input 4
// Pin 14 - DS DATA Pin 14 - input 5
// Pin 15 - relay 0 Pin 15 - input 6
// Pin 16 - Vcc Pin 16 - VDD Voltage IN (+)

int latchPin = 10; //Pin connected to latch pin (ST_CP) of 74HC595 PIN 12
int clockPin = 11; //Pin connected to clock pin (SH_CP) of 74HC595 PIN 11
int dataPin = 12; ///Pin connected to Data in (DS) of 74HC595 PIN 14
int loadlatch = 7; // Connects to Latch pin 9 of CD4021BE
int dataIn = 5; // Connects to the Data pin 3 (Q8) of CD4021BE
int clockIn = 6; // Connects to the Clock pin 10 of CD4021BE

void setup()
{ pinMode(latchPin, OUTPUT); //Pin connected to latch pin (ST_CP) of 74HC595 PIN 12
pinMode(dataPin, OUTPUT); //Pin connected to clock pin (SH_CP) of 74HC595 PIN 11
pinMode(clockPin, OUTPUT); ///Pin connected to Data in (DS) of 74HC595 PIN 14
pinMode(loadlatch, OUTPUT); // Connects to Latch pin 9 of CD4021BE
pinMode(clockIn, OUTPUT); // Connects to the Clock pin 10 of CD4021BE
pinMode(dataIn, INPUT); // Connects to the Data pin 3 (Q8) of CD4021BE
}

void loop()
{
digitalWrite(loadlatch,HIGH);
delayMicroseconds(10);
digitalWrite(loadlatch,LOW);
delayMicroseconds(10);
digitalWrite(clockIn,HIGH);
byte incoming = shiftIn(dataIn, clockIn, MSBFIRST);
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, incoming );

//1-8
digitalWrite(latchPin, HIGH);

}

Basically where I am now is trying to figure out how to turn the button presses into "latched" or push on/push off style of switch. I have gone through the tutorials for the latched buttons, but I dont know how to integrate that into the inputs of the CD4021BE.
And the sensitivity on the touch panel must be adjusted. I can place my finger 2mm away from the panel and it will activate a button press. I need to figure out how to adjust the sensitivity on the TTP226. The data sheet is poorly translated from a foreign language and its difficult to understand what they mean.

If anyone has any input that could help, I would love to see it!

@Merlot566jka: Please use code tags.

Read this before posting a programming question

Don't use "copy for forum" just copy the normal code and use code tags.

  digitalWrite(clockIn,HIGH);

Why are you doing that?

From what I read here ShiftIn Tutorial it said

//we will be holding the clock pin high 8 times (0,..,7) at the

//end of each time through the for loop

//at the begining of each loop when we set the clock low, it will
//be doing the necessary low to high drop to cause the shift
//register's DataPin to change state based on the value
//of the next bit in its serial information flow.
//The register transmits the information about the pins from pin 7 to pin 0
//so that is why our function counts down
  for (i=7; i>=0; i--)

So I figured I had to set it high for it to read the registers...

(and I appologize, I didn't read the rules before I posted, wont happen again)