user33108: Can I eat a piece in front of the enemy king with my king?
For example: My king was on b6, the enemy knight was on b5, and the enemy king was behind the knight on b4.
So can I capture the knight with my king, even if my king will then be in front of the enemy king?
Why can't I eat the piece in front of the enemy king?
[FEN "4k3/4p3/4K3/8/8/8/8/8 w - - 0 1"]


user26335: No.  Kings cannot move into a position to be captured by another piece.
Said differently, Kings may not move into check.
See also the FIDE Laws of Chess which clearly state:

3.9.1   The king is said to be 'in check' if it is attacked by one or more of the opponent's pieces, even if such pieces are constrained
from moving to the square occupied by the king because they would then
leave or place their own king in check.


3.9.2   No piece can be moved that will either expose the king of the same colour to check or leave that king in check.

The Black King defends this pawn. Thus, the White King may not capture that pawn because the White King would be moving to a square where it would be attacked by the Black King (illegal according to Section 3.9.2).
The OP contends that since a "King cannot capture a King" that the pawn capture is legal. This is simply not true. Section 3.9.2 does not allow the Kings to move within one square of each other. The fact that the Kings can't capture each other isn't relevant because such a move is illegal and results in an illegal position according to the Laws of Chess:

3.10.2    A move is illegal when it fails to meet the relevant requirements of Articles 3.1 – 3.9


3.10.3    A position is illegal when it cannot have been reached by any series of legal moves.

The diagram below each King's legal moves in the position with the pawn (left) and without the pawn (right).


33108: <p>Can I eat a piece in front of the enemy king with my king?</p>
<p>For example: My king was on b6, the enemy knight was on b5, and the enemy king was behind the knight on b4.</p>
<p>So can I capture the knight with my king, even if my king will then be in front of the enemy king?</p>
<p>Why can't I eat the piece in front of the enemy king?</p>
<pre><code>[FEN &quot;4k3/4p3/4K3/8/8/8/8/8 w - - 0 1&quot;]
</code></pre>
 26335: <p>No.  Kings cannot move into a position to be captured by another piece.
Said differently, Kings <a href="https://chess.stackexchange.com/a/8320/26335">may not move into check</a>.</p>
<p>See also the <a href="https://handbook.fide.com/chapter/E012018" rel="nofollow noreferrer">FIDE Laws of Chess</a> which clearly state:</p>
<blockquote>
<p>3.9.1   The king is said to be 'in check' if it is attacked by one or more of the opponent's pieces, even if such pieces are constrained
from moving to the square occupied by the king because they would then
leave or place their own king in check.</p>
</blockquote>
<blockquote>
<p>3.9.2   No piece can be moved that will either expose the king of the same colour to check or leave that king in check.</p>
</blockquote>
<p>The Black King defends this pawn. Thus, the White King may not capture that pawn because the White King would be moving to a square where it would be attacked by the Black King (illegal according to Section 3.9.2).</p>
<p>The OP contends that since a &quot;King cannot capture a King&quot; that the pawn capture is legal. This is simply not true. Section 3.9.2 does not allow the Kings to move within one square of each other. The fact that the Kings can't capture each other isn't relevant because such a move is illegal and results in an illegal position according to the Laws of Chess:</p>
<blockquote>
<p>3.10.2    A move is illegal when it fails to meet the relevant requirements of Articles 3.1 – 3.9</p>
</blockquote>
<blockquote>
<p>3.10.3    A position is illegal when it cannot have been reached by any series of legal moves.</p>
</blockquote>
<p>The diagram below each King's legal moves in the position with the pawn (left) and without the pawn (right).</p>
<p><a href="https://i.stack.imgur.com/qW2Lz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qW2Lz.png" alt="Diagram showing legal moves of both Kings." /></a></p>
