mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-12 11:55:32 +00:00
Merge pull request #12974 from keymanapp/fix/web/cherrypick-longpress-modifier-multitap-warning
fix(web): prevent multitap warning that occurs multitapping longpressable modifier keys 🏠
This commit is contained in:
commit
ac90d3df42
1 changed files with 23 additions and 10 deletions
|
|
@ -4,7 +4,7 @@ import VisualKeyboard from '../../../visualKeyboard.js';
|
|||
import { DeviceSpec, KeyEvent, ActiveSubKey, ActiveKey, KeyDistribution, ActiveKeyBase } from '@keymanapp/keyboard-processor';
|
||||
import { GestureSequence, GestureStageReport } from '@keymanapp/gesture-recognizer';
|
||||
import { GestureHandler } from '../gestureHandler.js';
|
||||
import { distributionFromDistanceMaps } from '@keymanapp/input-processor';
|
||||
import { correctionKeyFilter, distributionFromDistanceMaps } from '@keymanapp/input-processor';
|
||||
import Modipress from './modipress.js';
|
||||
import { keySupportsModipress } from '../specsForLayout.js';
|
||||
import { GesturePreviewHost } from '../../../keyboard-layout/gesturePreviewHost.js';
|
||||
|
|
@ -104,20 +104,33 @@ export default class Multitap implements GestureHandler {
|
|||
keyEvent.baseTranscriptionToken = this.baseContextToken;
|
||||
|
||||
const coord = tap.sources[0].currentSample;
|
||||
const baseDistances = vkbd.getSimpleTapCorrectionDistances(coord, this.baseKey.key.spec as ActiveKey);
|
||||
|
||||
const baseSpec = this.baseKey.key.spec;
|
||||
const baseDistances = vkbd.getSimpleTapCorrectionDistances(coord, baseSpec as ActiveKey);
|
||||
// If the key is on a different layer than is shown, what if the user meant to hit a different key?
|
||||
// (Bypass if the tap is part of a modipress gesture.)
|
||||
if(coord.stateToken != vkbd.layerId && !tap.matchedId.includes('modipress')) {
|
||||
const matchKey = vkbd.layerGroup.findNearestKey({...coord, stateToken: vkbd.layerId});
|
||||
|
||||
// Replace the key at the current location for the current layer key
|
||||
// with the multitap base key.
|
||||
const p = baseDistances.get(matchKey.key.spec);
|
||||
if(p == null) {
|
||||
console.warn("Could not find current layer's key")
|
||||
// That said, if they directly touched a non-output key, simplify and assume
|
||||
// that they hit the intended key.
|
||||
if(correctionKeyFilter(matchKey.key.spec)) {
|
||||
// Replace the key at the current location for the current layer key
|
||||
// with the multitap base key.
|
||||
const p = baseDistances.get(matchKey.key.spec);
|
||||
if(p == null) {
|
||||
console.warn("Could not find current layer's key")
|
||||
} else {
|
||||
baseDistances.delete(matchKey.key.spec);
|
||||
baseDistances.set(coord.item.key.spec, p);
|
||||
}
|
||||
}
|
||||
baseDistances.delete(matchKey.key.spec);
|
||||
baseDistances.set(coord.item.key.spec, p);
|
||||
}
|
||||
keyEvent.keyDistribution = this.currentStageKeyDistribution(baseDistances);
|
||||
|
||||
// Will also bypass if the base key is modipress-compatible.
|
||||
if(coord.item && correctionKeyFilter(coord.item.key.spec)) {
|
||||
keyEvent.keyDistribution = this.currentStageKeyDistribution(baseDistances);
|
||||
}
|
||||
|
||||
// TODO for future: multitap previews.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue