Gottox / terminal.js

Javascript terminal emulator library that aims to be xterm compliant and is supposed to work in browsers and node.js.
http://terminal.js.org
MIT License
593 stars 69 forks source link

AltGr + 3/4/5/6/7/8 = "#", "{", "[", "|", "`", "\" chars are not typed on French Keyboard. #102

Open VigibotDev opened 9 years ago

VigibotDev commented 9 years ago

Hello,

This is a JavaScript / Browser problem:

AltGr + 3/4/5/6/7/8 = "#", "{", "[", "|", "`", "\" are not typed on French Keyboard.

Same issue on project "term.js" There is an elegant way to solve this ?

Pascal

Gottox commented 9 years ago

Please recheck master

VigibotDev commented 9 years ago

Awesome and useful trick I test it tonight. Thanks a lot !!!!

Gottox commented 9 years ago

This should fix #97 too.

Gottox commented 9 years ago

Does it work?

VigibotDev commented 9 years ago

Sorry for the delay, I must launch terminal.js from node-webterm ASAP.

I want to replace term.js with terminal.js on my website, just need to work on the minimal socket.io implementaiton of terminal.js (don't need static I use Apache and it reverse proxy). And the missing Cut/Past.

Gottox commented 9 years ago

Copy should work as it, paste can easy be added:

<input type=text id="foo">
<input type=button onclick="terminal.write(document.getElementById('foo').value)">
VigibotDev commented 9 years ago

Just need to build before test... There is a "dist" (and minified) version inside the node package, but how I can get this from sources ?

Gottox commented 9 years ago
npm install; node_modules/.bin/grunt 
VigibotDev commented 9 years ago

you are too fast lol

VigibotDev commented 9 years ago

i just discovered grunt thanks:)

Gottox commented 9 years ago

fast by accident ;)

VigibotDev commented 9 years ago

NOK:( always AltGr + 3-to-8 not working (the \ produce always a backspace delete)

Gottox commented 9 years ago

Do you use vanilla node-webterminal to test? Which browser and OS?

VigibotDev commented 9 years ago

Firefox 40.0.3 / Windows Server 2012 R2 (not important, I tested on a lot of computer all the same) I think it must work with lasts browsers Firefox/Chrome/IE

What is Vanilla ? You can look my temporary client here (static served over Apache and websocket tunnel) http://www.serveurperso.com/temp/node-webterm/

I use special config to get many nodejs servers over Apache!

    RewriteEngine On
    RewriteCond %{REQUEST_URI} ^/(81|82)/socket.io [NC]
    RewriteCond %{QUERY_STRING} transport=websocket [NC]
    RewriteRule /(81|82)/(.*) ws://127.0.0.1:$1/$2 [P,L]
    ProxyPass /81/socket.io http://127.0.0.1:81/socket.io
    ProxyPassReverse /81/socket.io http://127.0.0.1:81/socket.io
    ProxyPass /82/socket.io http://127.0.0.1:82/socket.io
    ProxyPassReverse /82/socket.io http://127.0.0.1:82/socket.io
Gottox commented 9 years ago

Strange, for me it worked with the changes.

VigibotDev commented 9 years ago

I tested empty web cache, and another computer : Firefox 31.2.0 on Windows 7 same problem:(

VigibotDev commented 9 years ago

The keypress handler is perfect inside the Anyterm client (http://www.serveurperso.com/anyterm.html) and OK only for Firefox inside my term.js mod (http://www.serveurperso.com/terminal.php)

Gottox commented 9 years ago

Can you set a breakpoint to line 1384 and look for the value of String.fromCharCode(key)?

VigibotDev commented 9 years ago

OK

VigibotDev commented 9 years ago

I can add a realtime console.log();

Gottox commented 9 years ago

I think I need to use a windows instance to debug that, at least from linux, it looks fine.

I can debug it from a windows box tomorrow.

VigibotDev commented 9 years ago

This is a cool event test http://unixpapa.com/js/testkey.html my AltGr chars work on it there is a input box

VigibotDev commented 9 years ago

It's strange, my chars are never get from your function :

http://www.serveurperso.com/temp/node-webterm/index.html

// Taken from tty.js: https://github.com/chjj/tty.js
DomInput.prototype._keypress = function(ev) {
        var key = this.getKeyCode(ev);

console.log("Before " + String.fromCharCode(key));
        if (!key || ev.ctrlKey || ev.altKey || ev.metaKey) return;
console.log("After " + String.fromCharCode(key));

        if(ev.stopPropagation) ev.stopPropagation();
        if(ev.preventDefault) ev.preventDefault();
        this.push(String.fromCharCode(key));
        return false;
};
VigibotDev commented 9 years ago

I also tested with your input visible and focused. same problem (get any chars but not famous AltGr...).

VigibotDev commented 9 years ago

I discovered a working condition : Just commented out keydown event binding inside your DomInput. But this must create regression with other browser... We need a elegan way to make this. sorry for my bad english lol

function DomInput(target, buffer, opts) {
        DomInput.super_.apply(this, arguments);

        target.tabIndex = 0;
        this._input = document.createElement('input');
        this._input.style.width = this._input.style.height = this._input.style.opacity = '0';
        this._input.style.border = 'none';
        this._input.style.position = 'absolute';
        this._input.style.zIndex = -10000;
        target.parentNode.insertBefore(this._input, target);
        this._addListener(target, 'focus', this._focus);
        this._addListener(this._input, 'keypress', this._keypress);
        //ends._addListener(this._input, 'keydown', this._keydown);
}
Gottox commented 9 years ago

I think it's possible to merge both keypress and keydown into one event listener.

Gottox commented 8 years ago

Maybe related to https://github.com/zeit/hyperterm/issues/466