In C#, you can express characters for the KeyPress
event in the form Keys.Control | Keys.M
. In F#, Keys.Control ||| Keys.M
doesn't work. What does?
Edit: Interesting indeed. Using System.Windows.Forms.Keys.Control ||| System.Windows.Forms.Keys.M
as per Johannes Rössel's suggestion below in the F# interactive window works exactly as he shows. Writing it in a .fs file:
form.KeyPress.Add (fun e ->
if (e.KeyChar = (System.Windows.Forms.Keys.Control ||| System.Windows.Forms.Keys.M)) then textbox.SelectAll() )
gives me the error The type 'char' does not support any operators named '|||'
. So I probably misidentified the location of the problem. There is no typecasting from Keys
to char.