I am creating an Excel add-in written in VB.NET. I would like to bind KeyDown and KeyUp events to the spreadsheet to record when the user presses and releases the arrow keys while navigating the spreadsheet.
Ideally, these events would be built into Excel alongside the native SheetActivate and SheetSelectionChange events, for example. Alas, they are not.
Please note that I am NOT interested in the KeyDown/KeyUp events for Windows form controls, as I am not using a Windows form for this. Rather, I want to create these events at the Excel application, workbook, or worksheet level.
You could use the Windows API call
GetAsyncKeyStatein conjunction with theSelectionChangeeventHere’s a small VBA snippet to demonstrate