Get key press and release on ps2keyboard library

Hello everybody.

Recently I was testing the ps2keyboard library but for my project I need something that I think that the library does not have:

I need my arduino to know when a key is pressed and when a key is released, like if I had a push button on a digital pin.

I'm using this simple code:

#include <PS2Keyboard.h>

const int DataPin = 8;
const int IRQpin =  3;
PS2Keyboard keyboard;

void setup() {
  delay(1000);
  keyboard.begin(DataPin, IRQpin);
  Serial.begin(9600);
  pinMode(10, OUTPUT);
}

void loop() {
  if (keyboard.available()) {
    digitalWrite(10, HIGH);
    // read the next key
    char c = keyboard.read();
    Serial.print(c);
  }
  else {
    digitalWrite(10, LOW);
  }
}

So my point is: I need that when a key is pressed, the pin 10 would be constantly HIGH. And would turn LOW only when the key is released. Can somebody help me with that?

Have you tried any of the OTHER PS2 keyboard libraries?

PS2KeyAdvnced by Paul Carpenter
Ps2KeyboardHost by Steve Benz
PS2KeyRaw by Paul Carpenter
M10PS2 by PulseRain

I haven't tested yet john, thank you for your reply, I will test it today

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