Track View > Curve Editor or Dope Sheet> Highlight keys > Track View toolbar > Lock Selection
Keyboard > SPACEBAR
Lock Selection toggles selection locking on and off. When a selection is locked you can't inadvertently deselect or select anything else. When a selection is locked you don't have to click it to move the keys, you can click anywhere in the window to more or scale the keys.
Note: To use the Spacebar keyboard shortcut, the Keyboard Shortcut Override Toggle must be on.