It seems that there is an error in how the implementation of keyboard events on OS X is handled. An error is detected when several keys are pressed quickly or immediately.
Running my application on Win7, if I immediately press the "J" "K" "L" keys, I can always get all three keys (although not in any particular order). But in OS X, while running Windows Forms applications, I can get "JJJ" or "JKK" or "LLL". Nowhere on OS X is this behavior evident (Cocoa's own applications, such as TextEdit, behave identically to Win7).
Source code: (in Visual Studio, create a Windows forms project and edit the code of Form1):
public partial class Form1 : Form { public Form1(){ InitializeComponent(); KeyPress += Form1_KeyPress; KeyDown += Form1_KeyDown;} void Form1_KeyDown(object sender, KeyEventArgs e) {Console.WriteLine("KeyDown: " + e.KeyCode.ToString());} void Form1_KeyPress(object sender, KeyPressEventArgs e) {Console.WriteLine("KeyPress: " + e.KeyChar.ToString());} }
Work in Windows 7 (simultaneous pressing JKL):
KeyDown: L KeyPress: l KeyDown: J KeyPress: j KeyDown: K KeyPress: k
Runs on OS X (hits JKL immediately, note that it may take a few tries)
KeyDown: L KeyPress: k KeyDown: J KeyPress: k KeyDown: K KeyPress: k
If you missed it, all KeyPress events will be "k", the result will be "kkk". Why is this?
Update . I am running Mono 2.10.10 on Mountain Lion.
Mr. Smith
source share