Angular 5 + How To Move The Cursor Character By Character Using Keyboard Left/right Options In Ie 11
I am using Angular 5 with Ag-Grid Enterprise Addition. I am using IE11 browser. Unfortunately in the grid, the cursor gets stuck and not moving to next characters in the input box
Solution 1:
Below is the solution from which I achieved the task
var key = event.which || event.keyCode;
var iCaretPos = 0;
if(key === 37 || key === 39){
//Left or right
let inputDocument = document.getElementById('numericinput');
const element : HTMLInputElement = <HTMLInputElement>inputDocument;
event.stopPropagation();
let selectionStart = 0;
if(key === 39 && this.iCaretPos < element.innerHTML.length+1){
selectionStart = this.iCaretPos;
this.iCaretPos = this.iCaretPos +1;
}else if(key === 37 && this.iCaretPos !== 0){
selectionStart = this.iCaretPos;
this.iCaretPos = this.iCaretPos -1;
}
let selectionEnd = this.iCaretPos;
if (element.setSelectionRange) {
element.focus();
element.setSelectionRange(selectionStart, selectionEnd);
}
}
Post a Comment for "Angular 5 + How To Move The Cursor Character By Character Using Keyboard Left/right Options In Ie 11"