Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial fix for #9: English (0) and German (1) key remappings. #40

Merged
merged 1 commit into from
May 2, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions teletext-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -1296,6 +1296,8 @@ this.keypress = function(event) {
// Code 0 means there was simply no keypress.
if ( code == 0 ) { return; }

code = keymap(code);

// On Internet Explorer, ESC key triggers keypress too,
// so return since we've already handled ESC in keydown
if ( code == 27 ) { return; }
Expand Down Expand Up @@ -4080,6 +4082,56 @@ var init_font = function(charset) {
}


//////////////////
///// KEYMAP /////
//////////////////

// This is just a simple way of handling keypresses from other locales.
// If the incoming keypress code belongs to one of the variant characters
// associated with the character set we're using, we convert it to its
// correct teletext character set code.

var keymap = function(keypress) {

// English: pound sign
if ( cset == 0 && keypress == 163 ) { return 0x23; }

// English: hash
if ( cset == 0 && keypress == 35 ) { return 0x5f; }

// English: long dash (underscore)
if ( cset == 0 && keypress == 95 ) { return 0x60; }

// German: capital A with umlaut
if ( cset == 1 && keypress == 196 ) { return 0x5b; }

// German: lowercase a with umlaut
if ( cset == 1 && keypress == 228 ) { return 0x7b; }

// German: capital O with umlaut
if ( cset == 1 && keypress == 214 ) { return 0x5c; }

// German: lowercase o with umlaut
if ( cset == 1 && keypress == 246 ) { return 0x7c; }

// German: capital U with umlaut
if ( cset == 1 && keypress == 220 ) { return 0x5d; }

// German: lowercase u with umlaut
if ( cset == 1 && keypress == 252 ) { return 0x7d; }

// German: Eszett
if ( cset == 1 && keypress == 223 ) { return 0x7e; }

// German: section sign
if ( cset == 1 && keypress == 167 ) { return 0x40; }

// German: degree symbol
if ( cset == 1 && keypress == 176 ) { return 0x60; }

return keypress;
}

///////////////////////
///// HELP SCREEN /////
///////////////////////
Expand Down