From c87d387b7d854eca7336e0407463e7f3ac0d8afb Mon Sep 17 00:00:00 2001 From: EmaGht Date: Tue, 17 Apr 2018 10:48:27 +0200 Subject: [PATCH 1/3] Fix for Firefox copy/paste/cut browsers When you press CTRL+C, CTRL+V on firefox, for some reason it doesn't send "paste" or "copy" events, but a "keyup" event with "v" or "c" keyCode with a ctrlKey modifier. With this fix everything gets handled how it should --- src/input.handler.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/input.handler.ts b/src/input.handler.ts index fda736e..12dd177 100644 --- a/src/input.handler.ts +++ b/src/input.handler.ts @@ -112,6 +112,23 @@ export class InputHandler { return; } + //Copy/Cut, call the right methods + if(event.charCode == 118 && event.ctrlKey) + { + this.handlePaste(event); + return; + } + + if(event.charCode == 120 && event.ctrlKey) + { + this.handleCut(event); + return; + } + + //Paste. Nothing to do here + if(event.charCode == 99 && event.ctrlKey) + return; + let keyCode = event.which || event.charCode || event.keyCode; if (keyCode == undefined || [9, 13].indexOf(keyCode) != -1 || this.isArrowEndHomeKeyInFirefox(event)) { @@ -206,4 +223,4 @@ export class InputHandler { event.target.setSelectionRange(rawValueWithoutSuffixEndPosition, rawValueWithoutSuffixEndPosition); }, 0); } -} \ No newline at end of file +} From 3040d1ec42f5396bf75ddc65e9929455387d340d Mon Sep 17 00:00:00 2001 From: EmaGht Date: Tue, 17 Apr 2018 10:49:00 +0200 Subject: [PATCH 2/3] Fixed formatting --- src/input.handler.ts | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/input.handler.ts b/src/input.handler.ts index 12dd177..b852aa1 100644 --- a/src/input.handler.ts +++ b/src/input.handler.ts @@ -113,21 +113,21 @@ export class InputHandler { } //Copy/Cut, call the right methods - if(event.charCode == 118 && event.ctrlKey) - { - this.handlePaste(event); - return; - } - - if(event.charCode == 120 && event.ctrlKey) - { - this.handleCut(event); - return; - } - - //Paste. Nothing to do here - if(event.charCode == 99 && event.ctrlKey) - return; + if(event.charCode == 118 && event.ctrlKey) + { + this.handlePaste(event); + return; + } + + if(event.charCode == 120 && event.ctrlKey) + { + this.handleCut(event); + return; + } + + //Paste. Nothing to do here + if(event.charCode == 99 && event.ctrlKey) + return; let keyCode = event.which || event.charCode || event.keyCode; From 6053b6120a7bc1d88e6c6e482d61f1d1423c472a Mon Sep 17 00:00:00 2001 From: EmaGht Date: Tue, 17 Apr 2018 10:49:47 +0200 Subject: [PATCH 3/3] Additional formatting fix --- src/input.handler.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/input.handler.ts b/src/input.handler.ts index b852aa1..b3693ee 100644 --- a/src/input.handler.ts +++ b/src/input.handler.ts @@ -115,19 +115,19 @@ export class InputHandler { //Copy/Cut, call the right methods if(event.charCode == 118 && event.ctrlKey) { - this.handlePaste(event); - return; + this.handlePaste(event); + return; } if(event.charCode == 120 && event.ctrlKey) { - this.handleCut(event); - return; + this.handleCut(event); + return; } //Paste. Nothing to do here if(event.charCode == 99 && event.ctrlKey) - return; + return; let keyCode = event.which || event.charCode || event.keyCode;