elem.addEventListener('keyup', function(e){ var val = e.target.value.length == 1; e.keyCode == 13 ? val ? fn1(): fn2(): val ? fn3(): fn4(); }, false);