function KeyboardCtrl(keyboardConfig) {
  var ctrl = this;

  this.config = keyboardConfig;

  this.insertText = function(text) {
  	var element = document.getElementById(ctrl.targetId);
	
    var scrollPos = element.scrollTop;
    var strPos = element.selectionStart;

    element.value = element.value.slice(0, strPos) + text + element.value.slice(strPos);
    strPos = strPos + text.length;

    element.selectionStart = strPos;
    element.selectionEnd = strPos;
      
    element.scrollTop = scrollPos;
    element.focus();
    angular.element(element).triggerHandler('input');
  }
}

angular.module('scharwerk')
.constant('keyboardConfig', {
  'Α…Ω': ['Α', 'Β', 'Γ', 'Δ', 'Ε', 'Ζ'],
  'α…ω': ['α', 'β', 'γ', 'δ', 'ε', 'ζ']
})
.component('keyboard', {
  templateUrl: 'keyboard/_keyboard.html',
  controller: KeyboardCtrl,
  bindings: {
    targetId: '@',
    value: '='
  }
});
@@ -261,16 +261,55 @@
 onStart;
+%0A    var endPos = element.selectionEnd;
 %0A%0A    el
@@ -382,19 +382,19 @@
 e.slice(
-str
+end
 Pos);%0A  

fix keyboard on text replacement