About Monkey 2 › Forums › Monkey 2 Development › Keyx and Key.Raw in OnEvent
This topic contains 2 replies, has 2 voices, and was last updated by
abakobo
1 year, 5 months ago.
-
AuthorPosts
-
November 12, 2017 at 9:47 am #11651
1-Maybe I’ve missed somthing on how to use enums but..
When trying to us some Key.Raw mask within OnEvent I get no result..2-With an Azerty keyboard Key.Key1 is working as if the Keyboard was a Qwerty keyboard on W10 (you have to shift to get the numbers on Azerty’s), but on Mac and Linux I can have the Key.Key1 working only with the Key.Raw combination (and thus only withing OnRender with device.Keyboard.KeyDown as mentionned on point 1 of this topic)
How is it managed in ted2? There it works fine except for the numpad when numlock is off on Mac (doing both actions number+move)
Am I missing somthing or should I post an issue?
Here is a test code, you can switch the keyboard layout while the tester is running..
Monkey12345678910111213141516171819202122232425262728293031323334353637383940414243444546Namespace myapp#Import "<std>"#Import "<mojo>"Using std..Using mojo..Class MyWindow Extends WindowMethod New( title:String="Simple mojo app",width:Int=640,height:Int=480,flags:WindowFlags=Null )Super.New( title,width,height,flags )EndMethod OnRender( canvas:Canvas ) OverrideApp.RequestRender()canvas.DrawText( "Raw Key tester- press 1 or A with different keyboards (Qwerty/Azerty)",Width/2,Height/2,.5,.5 )If Keyboard.KeyDown (Key.A) Then Print "Key.A from OnRender"If Keyboard.KeyDown (Key.A|Key.Raw) Then Print "Key.A|Key.Raw from OnRender"If Keyboard.KeyDown (Key.Key1) Then Print "Key.Key1 from OnRender"If Keyboard.KeyDown (Key.Key1|Key.Raw) Then Print "Key.Key1|Key.Raw from OnRender"EndMethod OnKeyEvent( event:KeyEvent ) OverrideIf event.Key=Key.A Then Print "Key.A from on events"If event.Key=(Key.A|Key.Raw) Then Print "Key.A|Key.Raw from OnEvents"If event.Key=Key.Key1 Then Print "Key.Key1 from on events"If event.Key=(Key.Key1|Key.Raw) Then Print "Key.Key1|Key.Raw from OnEvents"EndEndFunction Main()New AppInstanceNew MyWindowApp.Run()EndNovember 12, 2017 at 7:01 pm #11657When trying to us some Key.Raw mask within OnEvent I get no result..
Key.Raw mask is only intended for use with keyboard.KeyDown, not events. KeyDown/KeyUp events are always virtual keys.
Use KeyChar events for ‘typed’ characters which are unicode and take into account local shift key layout etc.
In general use KeyDown for ‘control’ keys like arrows, ‘home’, ‘end’ etc. and KeyChar for ‘typed’ keys that have text/unicode representation.
November 14, 2017 at 8:35 am #11693Use KeyChar events for ‘typed’ characters
Ok Thanks!
There’s still the point n°2: The Key.Key0 to Key.Key9 is not behaving the same on Windows than on Mac/Linux (using an azerty keyboard). The way it is on Windows is the good one IMHO. i.e. Key.Keyx is considered as Raw (and on Mac/Linux you don’t get a Key.Keyx even if you shift).
-
AuthorPosts
You must be logged in to reply to this topic.