Assign keyboard shortcut to run procedure
For assigning a keyboard key to button on the sheet you can use this code, just copy this code to the sheet which contain the button.
Here Return
specifies the key and get_detail
is the procedure name.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.OnKey "{RETURN}", "get_detail"
End Sub
Now within this sheet whenever you press Enter button the assigned macro will be called.
According to Microsoft's documentation
On the Tools menu, point to Macro, and then click Macros.
In the Macro name box, enter the name of the macro you want to assign to a keyboard shortcut key.
Click Options.
If you want to run the macro by pressing a keyboard shortcut key, enter a letter in the Shortcut key box. You can use CTRL+ letter (for lowercase letters) or CTRL+SHIFT+ letter (for uppercase letters), where letter is any letter key on the keyboard. The shortcut key cannot use a number or special character, such as
@
or#
.Note: The shortcut key will override any equivalent default Microsoft Excel shortcut keys while the workbook that contains the macro is open.
If you want to include a description of the macro, type it in the Description box.
Click OK.
Click Cancel.