根据Hilog日志定位,查看日志关键字CapsLockState,日志CapsLockState为false,判断应用未使能CapsLock键。
A000FF/i.hmos.inputmethod:inputMethod/HMKeyboard_HardwareInputManager: onInputStart. check result currentCapsLockState: false, this.subType?.id: InputEnLowerService
参考以下代码使能CapsLock键:
import { inputDevice } from '@kit.InputKit';
import { BusinessError } from '@kit.BasicServicesKit';
@Entry
@Component
struct SetKeyEnabled {
aboutToAppear() {
try {
inputDevice.setFunctionKeyEnabled(inputDevice.FunctionKey.CAPS_LOCK, true).then(() => {
console.info(`Set capslock state success`);
}).catch((error: BusinessError) => {
console.error(`Set capslock state failed`, error);
});
} catch (error) {
console.error(`Set capslock enable error`);
}
}
build() {
Row() {
TextInput()
}
.height('100%')
.width('100%')
.padding(16);
}
}