Use a recommended method (#363)

This commit is contained in:
woxtu
2022-05-18 12:24:33 +09:00
committed by GitHub
parent c04015899b
commit 39774a83c5
5 changed files with 9 additions and 15 deletions

View File

@@ -37,7 +37,7 @@ export class PyInputBox extends BaseEvalElement {
let registrationCode = `${this.mount_name} = Element("${mainDiv.id}")`;
if (this.code.includes('def on_keypress')) {
this.code = this.code.replace('def on_keypress', `def on_keypress_${this.mount_name}`);
registrationCode += `\n${this.mount_name}.element.onkeypress = on_keypress_${this.mount_name}`;
registrationCode += `\n${this.mount_name}.element.addEventListener('keypress', on_keypress_${this.mount_name})`;
}
// TODO: For now we delay execution to allow pyodide to load but in the future this