diff options
author | Fabien Ménager <fabien.menager@gmail.com> | 2013-03-10 19:44:02 +0100 |
---|---|---|
committer | Fabien Ménager <fabien.menager@gmail.com> | 2013-03-10 19:44:02 +0100 |
commit | 6696b306cf85690843d4dbba1a54250e4179bfc4 (patch) | |
tree | 665148725f348ceef23339e0c82d86fc2bb89d01 /addons/webinterface.default | |
parent | 7904ea490cdf96797fbb1c696a9a7f12d2dab517 (diff) |
Handle letters and digits keystrokes in the web interface remote
Diffstat (limited to 'addons/webinterface.default')
-rwxr-xr-x | addons/webinterface.default/js/MediaLibrary.js | 53 |
1 files changed, 38 insertions, 15 deletions
diff --git a/addons/webinterface.default/js/MediaLibrary.js b/addons/webinterface.default/js/MediaLibrary.js index f97260ecff..8f63620c1d 100755 --- a/addons/webinterface.default/js/MediaLibrary.js +++ b/addons/webinterface.default/js/MediaLibrary.js @@ -126,25 +126,41 @@ MediaLibrary.prototype = { } var keys = { - 8: "back", // Back space - 13: "ok", // Enter - 27: "home", // Escape - 32: "playpause", // Space bar - 37: "left", // Left - 38: "up", // Up - 39: "right", // Right - 40: "down", // Down - 107: "volumeup", // + - 109: "volumedown" // - + 8: 'back', // Back space + 13: 'ok', // Enter + 27: 'home', // Escape + 32: 'playpause', // Space bar + 37: 'left', // Left + 38: 'up', // Up + 39: 'right', // Right + 40: 'down', // Down + 107: 'volumeup', // + + 109: 'volumedown' // - }; - var key = keys[event.which]; + var which = event.which; + var key = keys[which]; - if (key) { - event.data = { - key: key - }; + event.data = { + key: key + }; + + if (!key) { + event.data.key = 'text'; + + // Letters + if (which >= 65 && which <= 90) { + var offset = event.shiftKey ? 0 : 32; + event.data.text = String.fromCharCode(which + offset); + } + // Digits + if (which >= 96 && which <= 105) { + event.data.text = (which-96)+""; + } + } + + if (event.data.key) { this.pressRemoteKey(event); return false; } @@ -246,6 +262,13 @@ MediaLibrary.prototype = { }); } }); + case 'text': + return xbmc.rpc.request({ + 'method': 'Input.SendText', + 'params': { + 'text': event.data.text + } + }); } // TODO: Get active player |