JSFiddle - React, Tailwind, and code Playground
HTML
<textarea class="cancelEnter">ここは改行禁止</textarea>
<script>
$('.cancelEnter').bind('input keydown keyup keypress change',function(e){
if (e.which == 13) {
return false;
}
// 貼り付け対策のための次の改行削除コードを書くと、テキストが入力できなくなる
var replace_br = $(this).text().replace(/\r?\n/g,"");
$(this).text(replace_br);
})
</script>
<style>
textarea {width: 100%;height: 300px;}
</style>