From ef3e823982c02b5918adcde4eb19167aed1caf32 Mon Sep 17 00:00:00 2001 From: Daniel Cho Date: Thu, 29 Jul 2021 15:25:25 -0400 Subject: [PATCH] C2LC-430: Add keyboard shortcut for the share button --- docs/keyboard.md | 2 ++ src/App.js | 8 ++++++++ src/KeyboardInputSchemes.js | 11 +++++++++++ 3 files changed, 21 insertions(+) diff --git a/docs/keyboard.md b/docs/keyboard.md index 058f88bf..fab78129 100644 --- a/docs/keyboard.md +++ b/docs/keyboard.md @@ -33,6 +33,7 @@ follows. | Ctrl + Alt + p | playPauseProgram | | Ctrl + Alt + r | refreshScene | | Ctrl + Alt + s | stopProgram | +| Ctrl + Alt + z | shareEnvironment | | < | decreaseProgramSpeed | | > | increaseProgramSpeed | | ? | showHide | @@ -82,6 +83,7 @@ with the starting key of a sequence. Those key bindings are as follows: | Alt + p | playPauseProgram | | Alt + r | refreshScene | | Alt + s | stopProgram | +| Alt + z | shareEnvironment | | < | decreaseProgramSpeed | | > | increaseProgramSpeed | | ? | showHide | diff --git a/src/App.js b/src/App.js index 8a1da1f6..a77b291d 100644 --- a/src/App.js +++ b/src/App.js @@ -819,6 +819,9 @@ export class App extends React.Component { this.handleChangeCharacterPosition('turnRight'); } break; + case("shareEnvironment"): + this.handleShareButtonShortcut(); + break; default: break; } @@ -1006,6 +1009,11 @@ export class App extends React.Component { this.setState({keyBindingsEnabled: keyBindingsEnabled}); } + handleShareButtonShortcut = () => { + const currentUrl = document.location.href; + return navigator.clipboard.writeText(currentUrl); + } + render() { return ( diff --git a/src/KeyboardInputSchemes.js b/src/KeyboardInputSchemes.js index 9e870fef..fca01ec9 100644 --- a/src/KeyboardInputSchemes.js +++ b/src/KeyboardInputSchemes.js @@ -61,6 +61,9 @@ export type ActionName = // Update Program | "deleteAll" + + // Share Environment + | "shareEnvironment" ; type ActionKeyStep = { @@ -274,6 +277,10 @@ const VoiceOverInputScheme: KeyboardInputScheme = Object.assign({ keyDef: { code: "KeyR", key: "r", altKey: true}, actionName: "refreshScene" }, + shareEnvironment: { + keyDef: { code: "KeyZ", key: "z", altKey: true}, + actionName: "shareEnvironment" + }, showHide: { keyDef: { key: "?"}, actionName: "showHide" @@ -335,6 +342,10 @@ const NvdaInputScheme = Object.assign({ keyDef: { code: "KeyR", key: "r", altKey: true, ctrlKey: true }, actionName: "refreshScene" }, + shareEnvironment: { + keyDef: { code: "KeyZ", key: "z", altKey: true, ctrlKey: true }, + actionName: "shareEnvironment" + }, showHide: { keyDef: { key: "?", shiftKey: true }, actionName: "showHide"