Originally Posted by sohumsin
The result is the same, it depend stdout buffering.
Can we disable buffering?
Given that grep's --line-buffered option didn't make any difference, we can assume that the phenomenon is caused by xev's output buffering. xev's man page shows no options to control output buffering. One possibility is to modify the xev source code and rebuild it. Another possibility, given that xev writes to the terminal very quickly (unbuffered or line-buffered?) would be to intercept terminal writes and filter them as required. I don't know how to do that. Might be worth researching the "screen" and "script" commands.