jQueryを使用して最後にテキストを追加してから、キャレットを目的の位置に移動します。
$('#title').on('keyup', function(e) {
// Ignore if backspace is pressed
if(e.keyCode == 46){
return false;
}
// Set the value based on the current value length
// If it's longer than 3, "day" is already appended
this.value = (this.value.length<3)?this.value+="day":this.value;
// Move caret to the latest added character
var caretPos = this.value.length-3;
if(this.createTextRange) {
var range = this.createTextRange();
range.move('character', caretPos);
range.select();
}
else {
if(this.selectionStart) {
this.focus();
this.setSelectionRange(caretPos, caretPos);
}
else
this.focus();
}
});
ライブで動作するjsFiddleの例