Interesting problem. Your code is very simple, but in order to handle bi-directional PS/2 protocol, it's going to get more complex.
A couple of approaches to try:
- instead of using FALLING interrupt state, use the CHANGE mode. That way you get an interrupt on both falling and rising clocks. Measure the time between the rise and fall and you know how long the clock line was held. Depending on which way the data is flowing, you can then read bits on either low or high side of the clock.
- pulseIn might be a way to measure how long the clock interval is. Of course then you are not using interrupts and will have to be careful about when to read the data line.
- you could use a 'man in the middle' setup, where the clock lines from the host and device are wired to separate pins on the arduino. The software would have to echo the clock state to the other pin, but you would be able to detect whether it was the device or host yanking the clock line. But then the keyboard wouldn't work if the sniffer was off.
Note that on host-to-device packets the device sends and ACK bit. I'd also add code to detect invalid packets (bad start/stop/parity bit) and to timeout if the whole packet isn't sent.
If you haven't seen it already, this web page has really good info on PS/2 protocol:
http://www.computer-engineering.org/ps2protocol/
And SparkFun has a similar device to count keystrokes, you might get some hints from it:
HTH