Сделал "на коленке" минут за 5 (не засекал):
<input type="text" id="input" />
<div id="display"></div>
<script>
document.getElementById('input').addEventListener('input', function() {
document.getElementById('display').innerHTML = pack(this.value);
});
function pack(str) {
var last_char,
counter = 1,
res = [];
(str + '.').split('').forEach(function(char, i, list) {
if (last_char == char)
counter++;
else {
res.push(last_char);
if (counter > 1)
res.push(counter);
last_char = char;
counter = 1;
};
});
return res.join('');
};
</script>