txt.on('keydown', function() {
content = txt.val();
content = content.replace(/\n/g, '<br>');
hiddenDiv.html(content);
txt.css({
'min-height': hiddenDiv.height() + 10
});
});
$elem.on("click", handler);
$elem.on("keydown", handler);
function handler(event) {
if (event.type === "keydown") {
// ...
} else if (event.type === "click") {
// ...
}
// common functionality
}