Skip to content

Instantly share code, notes, and snippets.

@bossbojo
Created May 23, 2019 02:02
Show Gist options
  • Save bossbojo/47f12a2b5c6f3eb21002855a066fdaf0 to your computer and use it in GitHub Desktop.
Save bossbojo/47f12a2b5c6f3eb21002855a066fdaf0 to your computer and use it in GitHub Desktop.
onChangeLang(char) {
if (char.key === '*') return;
const th_char = 'ๅ/-ภถุึคตจขชๆไำพะัีรนยบลฟหกดเ้่าสวงผปแอิืทมใฝ';
const en_char = '1234567890-=qwertyuiop[]asdfghjkl;\'zxcvbnm,./';
if (th_char.match(char.key)) {
this.Barcode = this.Barcode.substring(0, this.Barcode.length - 1);
for (let i = 0; i < th_char.length; i++) {
if (th_char[i] === char.key) {
this.Barcode += en_char[i];
return;
}
}
}
}
/*
<input type="text" class="form-control" id="Barcode" placeholder="รหัสบาร์โค้ด" name="Barcode"
[(ngModel)]="Barcode" (keypress)="onChangeLang($event)" (keyup)="onChangeLang($event)">
*/
@bossbojo
Copy link
Author

nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment