diff options
author | Roman / Linnea Gräf <roman.graef@gmail.com> | 2022-09-04 17:43:28 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-04 17:43:28 +0200 |
commit | 8969ceea52d3d97a5fc3c2c747d8235c8af0f85e (patch) | |
tree | b47283409b703fa250f3b774645f7576bc8f6f43 | |
parent | 484bc7c89948d4c52a1f04fa97a06016fa0b5b4a (diff) | |
parent | 9e0bce2dc11ea0d43bf0a0451babf0e1c73f670c (diff) | |
download | neamoe-8969ceea52d3d97a5fc3c2c747d8235c8af0f85e.tar.gz neamoe-8969ceea52d3d97a5fc3c2c747d8235c8af0f85e.tar.bz2 neamoe-8969ceea52d3d97a5fc3c2c747d8235c8af0f85e.zip |
Merge pull request #1 from exhq/master
added paste support
-rw-r--r-- | src/jsMain/kotlin/moe/nea89/website/KConsole.kt | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/jsMain/kotlin/moe/nea89/website/KConsole.kt b/src/jsMain/kotlin/moe/nea89/website/KConsole.kt index 3c5fad1..a7b1102 100644 --- a/src/jsMain/kotlin/moe/nea89/website/KConsole.kt +++ b/src/jsMain/kotlin/moe/nea89/website/KConsole.kt @@ -1,5 +1,6 @@ package moe.nea89.website +import kotlinx.browser.window import kotlinx.browser.document import kotlinx.dom.addClass import kotlinx.html.InputType @@ -178,7 +179,11 @@ class KConsole( } fun keydown(event: KeyboardEvent) { - if (event.altKey || event.ctrlKey || event.metaKey) return + if (event.altKey || event.metaKey) return + if (event.ctrlKey) { + handleControlDown(event) + return + } if (event.isComposing) return if (state != ConsoleState.SHELLPROMPT) return if (justHandledInput) { @@ -208,4 +213,16 @@ class KConsole( rerender() scrollDown() } + + + fun handleControlDown(event: KeyboardEvent){ + if (event.key == "v"){ + event.preventDefault() + window.navigator.clipboard.readText().then { + input += it + rerender() + scrollDown() + } + } + } } |