I2CKeypad.h (Rob Tillaert) and .isPressed question

Acording to this post the consensus was that .isPressed() is used to detect if multiple keys are pressed at the same time.

However when reading the relevant Github on this library the following is written:

//  to check "press any key"
bool I2CKeyPad::isPressed()
{
  uint8_t a = _read(0xF0);
  if (a == 0xFF) return false;
  return (a != 0xF0);
}
}

Now I am using .isPressed to detect whether any single key is being pressed.

Is that now the wrong approach, and if so how then explain the above library lines?

that post refers to Keypad.h and the function does that

the link you give is for the I2CKeyPad library

Actually I think the consensus was that isPressed() does not tell you that keys are currently being pressed. It tells you if any keys have had a "key down" event since last read. The Op there wanted the current state, not last event, so had to write a new function.

However, it appears the I2CKeyPad::isPressed() is different, it gives the current state (I think).

"pressed" is a rather ambiguous term. It could mean Key down event, key is currently down, or even that key has been released. It seems the author of I2CKeyPad picked one of the alternative meanings.

1 Like

Hi @bobcousins and @J-M-L , I do use I2CKeypad.h, I had misread the library reference in that older post.

So, my question does actually refer to Rob Tillaerts's library.
Reading your answer Bob can I deduct that .isPRessed() actually returns a boolean reflecting the keypad pressed or not pressed status?

the comment seems pretty clear that it tells you if at least one key is pressed.

You could just try it out in a simple code

1 Like

Yes, I believe it does. ie. it looks for the current state.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.