[Mono-winforms-list] Incorrect, missing, and duplicate keypress events

xFleury fleurin at gmail.com
Fri Mar 8 02:14:49 UTC 2013

There appears to be a bug in how the OS X implementation of keyboard events
is handled. The bug reveals itself when either multiple keys are pressed in
rapid succession or all at once.

Running my app on Win7 if I hit the keys 'J' 'K' 'L' all at once, I can
always get all three keys (though not in any particular order). But on OS X,
while running Windows Forms applications, I can get 'JJJ' or 'JKK' or 'LLL'.
Nowhere else in OS X is this behavior exhibited (native Cocoa apps, such as
TextEdit, behave identical to Win7).

Source code: (in Visual Studio, create a windows forms project, and edit
Form1's code):

public partial class Form1 : Form
    public Form1(){
        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());}

Running on Windows 7 (hitting JKL all at once):

KeyDown: L
KeyPress: l
KeyDown: J
KeyPress: j
KeyDown: K
KeyPress: k

Running on OS X Mountain Lion, via Mono 2.10.10 (hitting JKL all at once;
note it can take a couple attempts)

KeyDown: L
KeyPress: k
KeyDown: J
KeyPress: k
KeyDown: K
KeyPress: k

If you missed it, all KeyPress events are 'k', the result was 'kkk'. Why is

View this message in context: http://mono.1490590.n4.nabble.com/Incorrect-missing-and-duplicate-keypress-events-tp4658863.html
Sent from the Mono - WinForms mailing list archive at Nabble.com.

More information about the Mono-winforms-list mailing list