C语言通过矩阵键盘控制数码管

我想用矩阵键盘控制数码管显示数字,结果数码管上显示的始终是121,

#include <REGX52.H>
#include "Delay.h"
#include "LCD1602.h"

int MatrixKey(unsigned char x)
{

P1=0xFF;

// while(1)
// {

    //列
P1=0x0F;
    if(P1_3==0)
    {
        Delay(20);while(P1_3==0);Delay(20);x+0;
    }
    else if(P1_2==0)
    {
        Delay(20);while(P1_2==0);Delay(20);x+1;
    }
    else if(P1_1==0)
    {
        Delay(20);while(P1_1==0);Delay(20);x+2;
    }
    else if(P1_0==0)
    {
        Delay(20);while(P1_0==0);Delay(20);x+3;
    }
    
    P1=0xF0;
    //行
        if(P1_7==0)
    {
        Delay(20);while(P1_7==0);Delay(20);x+0;
    }
    else if(P1_6==0)
    {
        Delay(20);while(P1_6==0);Delay(20);x+4;
    }
    else if(P1_5==0)
    {
        Delay(20);while(P1_5==0);Delay(20);x+8;
    }
    else if(P1_4==0)
    {
        Delay(20);while(P1_4==0);Delay(20);x+12;
    }

// }
return x;
}
void main()
{
unsigned char y,m;
LCD_Init();
while(1)
{

    LCD_ShowString(1,3,"Hello");
    y=MatrixKey();
    LCD_ShowNum(2,1,'y',3);
}

}