Search code examples
keypressopcodechip-8

FX0A opcode in chip 8 (Waiting for a keypress). if a key is already pressed, do I need to consider it a keypress?


The description of the opcode FX0A is:

Wait for a keypress and store the result in register VX

My question is if a key is already pressed while the opcode is called, is it considered a keypress? Or will it not be considered a keypress until the key is released and then pressed again?

In other words, do I need to wait until a value of a key is pressed, or until a value is set from not_pressed to pressed?


Solution

  • Fx0A - LD Vx, K Wait for a key press, store the value of the key in Vx. All execution stops until a key is pressed, then the value of that key is stored in Vx.

    (Source)

    If we take this literally, "wait for a key press" would imply no previous input, but to simply wait right here and now for a key.

    Though perhaps you should just make it configurable in your application.