|
|
|
@ -29,6 +29,8 @@ const KeyScaner = /** @class */ (function () {
|
|
|
|
|
// console.log('appendChar:', c, this.keybufs)
|
|
|
|
|
};
|
|
|
|
|
KeyScaner.prototype.onKeyDown = function (ev) {
|
|
|
|
|
var charCode = ev.key.charCodeAt(0);
|
|
|
|
|
|
|
|
|
|
this.lastTime = new Date().getTime();
|
|
|
|
|
if (ev.key == "Alt") {
|
|
|
|
|
if (ev.shiftKey || ev.ctrlKey || ev.metaKey) {
|
|
|
|
@ -51,7 +53,16 @@ const KeyScaner = /** @class */ (function () {
|
|
|
|
|
this.completeInput(); //立即完成输入
|
|
|
|
|
} else {
|
|
|
|
|
if (ev.key.length == 1) {
|
|
|
|
|
var charCode = ev.key.charCodeAt(0);
|
|
|
|
|
|
|
|
|
|
if (ev.altKey && ev.key === '0' && this.altBuf.length === 1 && this.altBuf[0] === '1') {
|
|
|
|
|
console.log('altBuf:', this.altBuf);
|
|
|
|
|
this.appendChar("\r");
|
|
|
|
|
// this.appendChar("enter");
|
|
|
|
|
this.altBuf = [];
|
|
|
|
|
this.completeInput();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// console.log("key="+charCode);
|
|
|
|
|
if (charCode >= 48 && charCode <= 57) {
|
|
|
|
|
if (ev.altKey) {
|
|
|
|
@ -75,18 +86,21 @@ const KeyScaner = /** @class */ (function () {
|
|
|
|
|
};
|
|
|
|
|
KeyScaner.prototype.onKeyUp = function (ev) {
|
|
|
|
|
this.lastTime = new Date().getTime();
|
|
|
|
|
if (ev.charCode === 29) {
|
|
|
|
|
/**
|
|
|
|
|
* if (ev.charCode === 29) {
|
|
|
|
|
var str = this.altBuf.join("");
|
|
|
|
|
var num = parseInt(str);
|
|
|
|
|
var c = String.fromCharCode(num);
|
|
|
|
|
this.appendChar(c);
|
|
|
|
|
this.altBuf = [];
|
|
|
|
|
console.log('onKeyUp success:', ev.charCode, this.keybufs);
|
|
|
|
|
} else if (ev.key == "Alt") {
|
|
|
|
|
} else
|
|
|
|
|
*/
|
|
|
|
|
if (ev.key == "Alt") {
|
|
|
|
|
if (this.altBuf && this.altBuf.length > 0) {
|
|
|
|
|
var str = this.altBuf.join("");
|
|
|
|
|
var num = parseInt(str);
|
|
|
|
|
var c = String.fromCharCode(num);
|
|
|
|
|
|
|
|
|
|
this.appendChar(c);
|
|
|
|
|
this.altBuf = [];
|
|
|
|
|
}
|
|
|
|
@ -98,14 +112,16 @@ const KeyScaner = /** @class */ (function () {
|
|
|
|
|
KeyScaner.prototype.onKeyPress = function (ev) {
|
|
|
|
|
this.lastTime = new Date().getTime();
|
|
|
|
|
const char = String.fromCharCode(ev.charCode);
|
|
|
|
|
console.log('KeyPress:', ev.charCode, char);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* if (ev.charCode === 29) {
|
|
|
|
|
this.appendChar(char);
|
|
|
|
|
// console.log('KeyPress success:', ev.charCode, this.keybufs);
|
|
|
|
|
} else
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
if (char == '\n') {
|
|
|
|
|
this.appendChar("\r");
|
|
|
|
|
this.completeInput();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|