keyboard.shiftkey not working in keydown?

I have this code in a listbox keydown event and the shiftkey isn’t being recognized. Suggestions?

If Key = ChrB(9) Then//Tab If column = 5 Then Beep ElseIf column < 5 Then//Tab me.EditCell(row, column+1) Return True ElseIf Keyboard.AsyncShiftKey And Column > 0 Then//Tab me.EditCell(row, Column-1) Return True End If End If

I think you should use Keyboard.ShiftKey instead of Keyboard.AsyncShiftKey

http://documentation.xojo.com/index.php/Keyboard.ShiftKey

Is the shift key only important if column > 5? You’re handling everything through column = 5 without looking at the shift key.

Thanks for responding. I’ve tried with and without with no success.
Scott What do you mean by column >5?

  ElseIf Keyboard.AsyncShiftKey And Column > 0 Then//Tab

Doesn’t this catch the key ? I know I don’t have an
=true

Rewrote your code for a number of (internal, my brain works a different way) reasons and it seems to be working fine on Mac OS 10.11.6 here.

Function CellKeyDown(row as Integer, column as Integer, key as String) Handles CellKeyDown as Boolean
  if Key = ChrB(9) then
    dim iDestinationCol as Integer = column + 1
    if Keyboard.AsyncShiftKey = true then
      // Step backwards
      iDestinationCol = column - 1
      
    end
    
    // Protect against OOB
    if (iDestinationCol < 0) or (iDestinationCol > (me.ColumnCount - 1)) then
      beep
      return false
    end
    
    me.EditCell(row, iDestinationCol)
    
  end
End Function

Also, was very surprised that ListBox didn’t already behave like this.

Your logic basically says, “Only check the shift key if the column is greater than 5”.

Thanks Tim Hare. Sometimes my lack of logic amazes me.
Thanks Tim Parnell. I appreciate the code and the insight to a different thinking process.

Paul is correct. In a Keydown event, don’t use the Async versions.

Ah! I did not know about that. For anyone else who’s curious, here’s (from the docs) why that is. Emphasis mine.

Here’s the updated code. In this listbox, the entries beyond the 5th column are readonly.
This is much cleaner.

If Key = ChrB(9) Then//Tab Dim iDestinationCol as Integer = column If Keyboard.ShiftKey = True Then// Step backwards iDestinationCol = iDestinationCol-1 If iDestinationCol = -1 Then iDestinationCol = 5 Beep End If ElseIf Keyboard.ShiftKey = False Then//Step forwards iDestinationCol = iDestinationCol+1 If iDestinationCol = 6 Then iDestinationCol = 0 Beep End If End If me.EditCell(row, iDestinationCol) End If Return False