String.fromCharCode 函数如何在 html 输入字段中用于移动键盘
                
             
            
            
                <p>我想捕获键盘按键代码并将其转换为字符。我正在使用 String.fromCharCode javascript 函数,但它仅适用于计算机键盘,不适用于移动键盘。任何帮助将不胜感激。</p>
<pre class="brush:php;toolbar:false;">$(".inputsmeter").keyup(function (e) { 
  let key = e.which; 
  let c = String.fromCharCode(key); 
  alert(c); 
});</pre></p>            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
         
        
        
这在我的 iOS Safari 15 上按预期运行。 在输入中键入
a将看到警告打印: