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
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
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