Adicwu
V2EX  ›  React

mac 系统中, input 在输入中文时按回车,会触发 enter 事件,如何隔离这种行为(像 windows 一样)

  •  
  •   Adicwu · Mar 4, 2024 · 2186 views
    This topic created in 981 days ago, the information mentioned may be changed or developed.
    Adicwu
    Adicwu
    OP
    Mar 4, 2024
    1
    已解决
    LinYaXuan
    LinYaXuan
    Mar 4, 2024
    2
    https://greasyfork.org/zh-CN/scripts/470612-chagpt-safari-中文输入法回车键修复/code
    参考这个扩展一下匹配网站应该能解决 web 上的问题。
    代码很短
    ```js
    document.addEventListener(
    "keydown",
    (e) => {
    if (e.keyCode == 229) e.stopPropagation();
    },
    true
    );

    ```
    Adicwu
    Adicwu
    OP
    Mar 5, 2024
    3
    @LinYaXuan keyCode 已弃用;最后用 compositionstart/compositionend 配合 keydown 实现的
    devzhaoyou
    devzhaoyou
    Mar 22, 2024
    4
    这个问题 gpt 不很容易答出来么
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1014 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 19:05 · PVG 03:05 · LAX 11:05 · JFK 14:05
    ♥ Do have faith in what you're doing.