King
The king moves one square in any direction and may never move onto an attacked square.
A king is not captured. A game ends when the king is checkmated, which means it is attacked and no legal response remains.
Legal king moves
The king can move to any adjacent square, but only when that square is not occupied by a friendly piece or attacked by the opponent. This restriction applies even when moving the king would capture an attacking piece.
Move the king from d4 to any legal adjacent square.
Move the king from d4 to any legal adjacent square.
Check changes which moves are legal
A player in check must remove the attack immediately. The king may move, the attacking piece may be captured, or the attack may be blocked when the checking piece attacks along a line. A move that leaves the king in check is illegal.
The two kings can never stand on adjacent squares because each king attacks every adjacent square.
The king in the opening
The king usually reaches safety by castling rather than walking toward a corner one square at a time. Castling is a separate king move with extra conditions, so it should not be inferred from the king's normal movement rule.