Skip to content

Commit eda3ea2

Browse files
committed
Fixed Firefox event bug, updated readme
1 parent eb6a5a4 commit eda3ea2

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

README.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,11 @@ plainterm.init(settings);
108108
| `onCommand` | Existing command executed |
109109
| `onCommand404` | Non-existing command executed |
110110
| `onProcessStart` | Process started |
111-
| `onProcessStop` | Process stopped |
111+
| `onProcessStop` | Process stopped |
112+
113+
Events are being dispatched by the inititial terminal container passed on init, for example:
114+
115+
```
116+
const term = document.getElementById('terminal');
117+
term.addEventListener('onCommand', e => console.log("known command executed!"));
118+
```

build/plainterm.js.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "plainterm.js",
3-
"version": "0.4.4",
3+
"version": "0.4.5",
44
"description": "A dead simple lightweight pure Javascript terminal \"emulator\" that mimics terminal behaviour in browser.",
55
"main": "plainterm.js",
66
"devDependencies": {

plainterm.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ var plainterm = (function() {
120120
container.className = "terminal-container";
121121
input_container.className = "terminal-type";
122122
input.setAttribute("type", "text");
123-
input.setAttribute("onkeypress", "plainterm.eval(this)");
123+
input.setAttribute("onkeyup", "plainterm.eval(event, this)");
124124
dom.appendChild(container);
125125
dom.appendChild(input_container);
126126
for (var e of document.getElementsByClassName("terminal-type")) {
@@ -174,7 +174,8 @@ var plainterm = (function() {
174174
}
175175

176176
//Reads text on Enter press
177-
function run(cmd) {
177+
function run(event, cmd) {
178+
event = event || window.event;
178179
if(event.keyCode == 13) {
179180
println(cmd.value, true);
180181
if (cmd.value.length > 0) {

0 commit comments

Comments
 (0)