A king cannot enter the pawn’s capture tiles. When you will play chess online you can check it doesn’t allow the king to move in the tiles where it can be captured.