文本框内的自动热键

Automatic hotkeys within textbox

我正在尝试创建一个带有简单用户输入文本框的网页,当键入某些组合时将产生特定的热键结果。

想象 Autohotkey 但不是 运行 在 PC 上 运行 在网页上。

例如,如果有人在用户文本框中输入 "repair",这将更改为

  1. 做了 x 件事
  2. 在这里做了另一件事
  3. 修复完毕

(这只是一个例子)

如何在单个网页上进行设置?

找到解决方法如下

在第 3 行和第 4 行中,将 hotkeyhere 替换为您希望在键入时替换的内容

它说 Textreplace here 将其替换为您想要的文本替换为

$(document).keypress(function() {
var textarea=$('#txt'); 
textarea.val(textarea.val().replace(/hotkeyhere/g,"Textreplace here"));
textarea.val(textarea.val().replace(/hotkeyhere/g,"Textreplace here")); 
});
$(document).ready(function(){
$('#copy').on('click', function(){
clipBoardValue = '';
$('#myForm').find('.input').each(function(){
if($(this).attr('type')== 'radio' ){
  if($(this).is(':checked')){
    clipBoardValue = clipBoardValue + ' ' + $(this).val();
  }
}else{
  clipBoardValue = clipBoardValue + ' ' +$(this).val();
}
});
console.log(clipBoardValue+ ' copied to clipboard');
copyToClipboard(clipBoardValue);
return false;
});
});