When using a textarea with a keydown event, I noticed that when typing and then moving the cursor to the middle and pressing the right arrow key, the next letter gets highlighted. Is there a way to prevent this highlighting from occurring? Interestingly, when using the left arrow key, the letter does not get highlighted. Any insights on how to resolve this issue would be greatly appreciated. Thank you!
<div ng-app="myApp">
<div class="container" ng-controller="Ctrl_List">
<div class="row">
<textarea name="text" id="text" cols="30" rows="10" ng-keydown="keyPress();"></textarea>
</div>
</div>
angular.module('myApp', [])
.controller("Ctrl_List", ["$scope", function(scope) {
scope.keyPress = function(){
var code = event.which;
if (code == 37) {
event.preventDefault();
document.activeElement.selectionStart--;
document.activeElement.selectionEnd--;
}
if (code == 39) {
event.preventDefault();
document.activeElement.selectionStart++;
document.activeElement.selectionEnd++;
}
}
}]);