Name your "context".
If flash is not "focused" and you expect to capture keyboard input, you can't do it. In other words, flash is not your catalyst to a keylogger.
If your context is flash and the user has it activated (clicked on), then you can get any keyboard input you like.
Which is it?