Help with keydown

Hi everybody!

How are yout guys?

i have this piece of code on a desktopwindow keydown event:

If DebugBuild and Keyboard.CommandKey Then
  // Verifica as setas com Command pressionado
  Select Case key.Asc
    
  Case 29 // Right Arrow // próxima fase
    
    if DebugBuild then
      gameLevelLimit = gameLastLevel
    End If
    if gameLevel<gameLevelLimit then // no máximo 31 levels
      gameLevel = gameLevel + 1
    End If
    
    wdwGame.Close
    wdwGame.show
    
  Case 28 // Left Arrow // volta uma fase
    
    if gameLevel>1 then
      gameLevel = gameLevel - 1
    End If
    wdwGame.Close
    wdwGame.show
    
  Case 45 // - // tira um rato
    
    if gameMices>1 then
      gameMices = gameMices - 1
    End If
    
  Case 61 // + // adiciona um rato
    
    gameMices = gameMices + 1
    
  Case 108 // LEVEL // para abrir o editor de fases
    
    wdwGame.Close
    wdwEditor.show
    
  End Select

Here:
If DebugBuild and Keyboard.CommandKey Then
I tried alt, control and option on Windows to do the same, but i’m stuck…

i can’t do the same as i was doing on mac…

What’s the trick?

Thank you,

Alex

Have you tried Keyboard.AsyncControlKey?

not yet…

tested, did not work.

with shift and control and arrow, it changes the level. only this works.

On Windows, CommandKey is the same as OSKey, the key with the windows logo. Note that many combinations are intercepted by the OS and never reach your program.

Edit: the arrow keys are intercepted and will not reach your program.

sorry, I didn’t understand your explanation.

ascii code for arrow key is the same on Mac, windows, linux, right?
the char “L” also have the same code, right?

so, why I can’t intercept “windows L” on windows the same way I intercept “command L” on Mac?

Windows + L is bound to the system, it’s the shortcut to lock your workstation and allowing applications to intercept that would present a security issue. You’ll find this to be true with the Windows key more often than not.

1 Like

You’ll find that most of the Command and Alt key sequences belong to the OS and will never make it to a KeyDown event.