keyboardevent-chobun

e.kana, e.char追加

目前为 2025-03-22 提交的版本。查看 最新版本

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.gf.qytechs.cn/scripts/530545/1558131/keyboardevent-chobun.js

  1. const code2Kana = {
  2. "Digit3": "あ", "KeyE": "い", "Digit4": "う", "Digit5": "え", "Digit6": "お",
  3. "KeyT": "か", "KeyG": "き", "KeyH": "く", "Quote": "け", "KeyB": "こ",
  4. "KeyX": "さ", "KeyD": "し", "KeyR": "す", "KeyP": "せ", "KeyC": "そ",
  5. "KeyQ": "た", "KeyA": "ち", "KeyZ": "つ", "KeyW": "て", "KeyS": "と",
  6. "KeyU": "な", "KeyI": "に", "Digit1": "ぬ", "Comma": "ね", "KeyK": "の",
  7. "KeyF": "は", "KeyV": "ひ", "Digit2": "ふ", "Equal": "へ", "Minus": "ほ",
  8. "KeyJ": "ま", "KeyN": "み", "Backslash": "む", "Slash": "め", "KeyM": "も",
  9. "Digit7": "や", "Digit8": "ゆ", "Digit9": "よ",
  10. "KeyO": "ら", "KeyL": "り", "Period": "る", "Semicolon": "れ", "IntlRo": "ろ",
  11. "Digit0": "わ", "KeyY": "ん",
  12. "IntlYen": "ー", "BracketLeft": "゛", "BracketRight": "゜",
  13. "Space": "_",
  14. "Escape": ""
  15. }
  16.  
  17. const code2ShiftKana = {
  18. "Digit3": "ぁ", "KeyE": "ぃ", "Digit4": "ぅ", "Digit5": "ぇ", "Digit6": "ぉ",
  19. "KeyZ": "っ", "Digit7": "ゃ", "Digit8": "ゅ", "Digit9": "ょ", "Digit0": "を",
  20. "Comma": "、", "Period": "。", "Slash": "・", "BracketRight": "「", "Backslash": "」"
  21. };
  22.  
  23.  
  24.  
  25. Object.defineProperty(KeyboardEvent.prototype, "kana", {
  26. get() {
  27. return this.shiftKey && code2ShiftKana[this.code] ? code2ShiftKana[this.code] : code2Kana[this.code];
  28. }
  29. });
  30.  
  31. Object.defineProperty(KeyboardEvent.prototype, "char", {
  32. get() {
  33. return this.key === " " ? "_" : this.key === "Escape" ? "" : this.key;
  34. }
  35. });

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址