vscode how to add keyboard shortcut for staging selected lines

The accepted answer didn't work for me so I raised a ticket on GitHub:

When condition for Source Control View for better keybindings #99683

The following did:

{
  "key": "ctrl+a",
  "command": "git.stageAll",
  "when": "sideBarFocus && activeViewlet == 'workbench.view.scm'"
},
{
  "key": "ctrl+s",
  "command": "git.stage",
  "when": "sideBarFocus && activeViewlet == 'workbench.view.scm'"
},
{
  "key": "ctrl+u",
  "command": "git.unstage",
  "when": "sideBarFocus && activeViewlet == 'workbench.view.scm'"
},

UPDATE:

I was also able to get single keys working via the addition of the listFocus attribute:

{
  "key": "s",
  "command": "git.stage",
  "when": "listFocus && sideBarFocus && activeViewlet == 'workbench.view.scm'"
},

In case anyone is still looking for this:

The commands stageSelectedRanges, unstageSelectedRanges, revertSelectedRanges have been introduced a while ago. Note that there is currently a related bug in VSCode: the diff view does not refresh after a partial stage - but apart from that it works like a charm.

This is how I set it up in my keybindings:

{
  "key": "s",
  "command": "git.stageSelectedRanges",
  "when": "isInDiffEditor && editorTextFocus"
},
{
  "key": "u",
  "command": "git.unstageSelectedRanges",
  "when": "isInDiffEditor && editorTextFocus"
},
{
  "key": "r",
  "command": "git.revertSelectedRanges",
  "when": "isInDiffEditor && editorTextFocus"
}