I've asked this question at the FreePascal site, but haven't received a reply for over a week, so I'm trying here as well:

I want to use the Keyboard unit that comes with FreePascal to keep track of which keys are currently pressed. In my code I have an array of all keys. I can set a key as pressed by using PollEvent to get keypress events, but I'm unable to get an event when the key is released. It is my understanding that the kbReleased flag should indicate a key release event, but I'm never getting this flag. Here's an excerpt from my test code:

[pascal]
Repeat
K:=GetKeyEvent;
K:=TranslateKeyEvent(K);
Write('Got key event with ');
Case GetKeyEventFlags(K) of
kbReleased : Writeln('Released key event');
end;
Writeln('Got key : ',KeyEventToString(K));
Until (GetKeyEventChar(K)='q');
[/pascal]

It reads keypresses as it should, but I never get the 'Released key event' message.