digital read/write not working within switch/case serial loop

    if ( mode == 0 && key == 4 && val == 1){ mode = 1;}
    if ( mode == 0 && key == 5 && val == 1){ mode = 2;}
    if ( mode == 0 && key == 13 && val == 1){ mode = 3;}

Nested ifs would make this clearer.

    if ( mode == 0 && val == 1)
    {
       if (key == 4)
          { mode = 1;}
       if (key == 5)
          { mode = 2;}
       if (key == 13)
          { mode = 3;}
    }
My problem is as soon as I move this to within the IF variables in the code
it stops working.

You can't move stuff into the IF variables. Into the if statement block, yes. But, you need to show WHERE you moved that to.

I am assuming it is something to do with the fact it is working alongside the serial input (which all works great)
but I cannot see why.

I can't see any basis for that assumption.

Put each { and } on a new line, and use Tools + Auto Format to properly indent your code. That may make your problem apparent. If not, post the code you are having problems with, without commented out code.