Replies: 3 comments 3 replies
-
When you say this can be seen via I've recently been testing a lot of terminals and seeing what keys are recognised; I don't believe I've seen one that processed Shift+Enter as anything other than Enter. As it stands right now, if the terminal emulator you're using doesn't tell Textual that a different key combination was pressed, Textual can't know. #3411 might be interesting here but it's not something we've looked into yet, and I don't personally know if it would actually allow this. |
Beta Was this translation helpful? Give feedback.
-
yes, in |
Beta Was this translation helpful? Give feedback.
-
I had the same issues, so I made a quick hack that works surprisingly well for only Windows 11 in PowerShell (don't use this unless you are only using this for PowerShell): from textual.widgets import TextArea
import time
class InputTextField(TextArea):
default_text_height = 5
DEFAULT_CSS = """
InputTextField {
height: 5;
}
"""
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self.last_key_time = None
self.last_key = None
def _on_key(self, event) -> None:
current_time = time.time()
key = event.key
# Shift+Enter (Tested on Windows terminal, have not verified linux or mac)
if self.last_key == "f12" and key == "c" and self.last_key_time and current_time - self.last_key_time < 0.01:
self.insert("\n")
event.prevent_default()
elif (key == "enter"):
event.prevent_default()
# TODO: Submit content here
self.styles.height = self.default_text_height
self.last_key = key
self.last_key_time = current_time |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm having difficulty either binding or capturing via on_key the shift+enter combination. It appears to always come in to textual as an "enter". Is there a way to do this?
This can be seen via the
textual keys
tool.Beta Was this translation helpful? Give feedback.
All reactions