You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Keyman CLI编译报错及警告求助:旧版本文件与按键规则问题

自定义Keyman键盘脚本编译问题及解决方法

问题描述

1. 版本命令无效错误

使用kmc编译自定义Keyman键盘脚本时,初始脚本中通过store(&VERSION) '1.0'定义版本,触发以下编译问题:

  • 警告:KM02081: The keyboard file is an old version
  • 错误:KM0200D: Invalid 'version' command

初始脚本片段:

c My Fantasy Script Keyboard
store(&VERSION) '1.0'
store(&NAME) 'My Fantasy Script'
store(&BITMAP) 'fntsy.ico'
store(&LAYOUTFILE) 'fntsy.kmn'
store(&TARGETS) 'windows macosx linux web'

begin Unicode > use(main)

group(main) using keys
+ '0' > U+00A1 c Mapping for the '0' key
+ '1' > U+00A6 c Mapping for the '1' key
+ '2' > U+00A2 c Mapping for the '2' key
+ '3' > U+00A3 c Mapping for the '3' key
+ '4' > U+00A5 c Mapping for the '4' key
+ '5' > U+00A4 c Mapping for the '5' key
+ '6' > U+00A9 c Mapping for the '6' key
+ '7' > U+00A7 c Mapping for the '7' key
+ '8' > U+00AB c Mapping for the '8' key
+ '9' > U+00AE c Mapping for the '9' key

编译命令及输出:

$ kmc build --color --debug fntsy.kmn
fntsy.kmn - info KM05002: Building fntsy.kmn
fntsy.kmn:2 - warn KM02081: The keyboard file is an old version
fntsy.kmn:2 - error KM0200D: Invalid 'version' command
fntsy.kmn - info KM05007: fntsy.kmn failed to build.

2. 按键规则字符过多警告

将store(&VERSION)改为'17.0'后,编译通过但出现大量KM02084: There are too many characters in the keystroke part of the rule警告,问题规则示例:

group(main) using keys
+ 'I$&--@_^' [K_TAB] > 'I%9440005' c Mapping for the 'I$&--@_^' key, the vowel i with stress, lengthening, tense, stress, nasalization and extra low tone
+ 'I$&-@_^' [K_TAB] > 'I%940005' c Mapping for the 'I$&-@_^' key, the vowel i with stress, lengthening, tense, stress, nasalization and low tone
+ 'I$&++@_^' [K_TAB] > 'I%9330005' c Mapping for the 'I$&++@_^' key, the vowel i with stress, lengthening, tense, stress, nasalization and extra high tone
+ 'I$&+@_^' [K_TAB] > 'I%930005' c Mapping for the 'I$&+@_^' key, the vowel i with stress, lengthening, tense, stress, nasalization and high tone

解决方法

针对版本命令无效错误

Keyman 10及后续版本已废弃store(&VERSION)语法,改用文件顶部的version指令定义版本,替换原脚本中的版本定义行即可:

version 17.0

针对按键规则字符过多警告

警告的核心原因是误解了Keyman规则语法:规则左侧的'I$&--@_^'会被解析为连续输入多个字符的组合键,而非单个按键的映射,Keyman对组合键的字符长度有限制,因此触发警告。

推荐以下几种正确实现方式:

方案1:修饰键绑定

将语音特征(重音、长音等)绑定到Shift/Ctrl/Alt等系统修饰键,实现组合键映射:

group(main) using keys
+ 'I' > 'I'
+ Shift 'I' > 'I$'  // Shift+I 输出带重音的I
+ Ctrl 'I' > 'I&'   // Ctrl+I 输出带长音的I
+ Shift+Ctrl 'I' > 'I$&'  // 组合修饰键输出带多重特征的I

方案2:状态切换(推荐)

通过store定义状态标记,用特定按键切换状态后,输入基础键即可生成对应特征的字符:

store(Stress) '0'
store(Lengthen) '0'

group(main) using keys
// 切换重音状态
+ '^' > set(Stress, '1') c 开启重音
+ '_' > set(Stress, '0') c 关闭重音
// 切换长音状态
+ '-' > set(Lengthen, '1') c 开启长音
+ '+' > set(Lengthen, '0') c 关闭长音
// 根据当前状态输出对应字符
+ 'I' > if(Stress='1' and Lengthen='1') then 'I$&' 
        else if(Stress='1') then 'I$' 
        else if(Lengthen='1') then 'I&' 
        else 'I' 
        endif endif endif

方案3:层级键盘

定义多层键盘布局,通过特定按键切换到修饰层,输入标记完成特征组合:

begin Unicode > use(main)

group(main) using keys
+ 'I' > use(vowel_modifiers) c 输入I后进入元音修饰层
+ '0' > U+00A1

group(vowel_modifiers) using keys
+ '-' > 'I$&-' c 添加长音标记
+ '+' > 'I$&+' c 添加高音标记
+ K_ESC > use(main) c 返回主键盘层

内容的提问来源于stack exchange,提问作者Lance Pollard

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.21 23:30:11