mirror of
https://github.com/Alamantus/Lexiconga.git
synced 2025-05-23 10:30:05 +02:00
15 lines
No EOL
524 B
JavaScript
15 lines
No EOL
524 B
JavaScript
import digraphs from './digraphs.json';
|
|
import { setSelectionRange, insertAtCursor } from '../../StackOverflow/inputCursorManagement.js';
|
|
|
|
export function usePhondueDigraphs(event) {
|
|
let val = event.target.value;
|
|
let pos = event.target.selectionStart || val.length;
|
|
|
|
const key = typeof event.which !== "undefined" ? event.which : event.keyCode,
|
|
digraph = digraphs[val.substr(pos - 1, 1) + String.fromCharCode(key)];
|
|
|
|
if (digraph) {
|
|
event.preventDefault();
|
|
insertAtCursor(event.target, digraph, -1);
|
|
}
|
|
} |