I gave you a “keydown” listener that does exactly that, in How to expand node's size dynamically when the text in its textBlock is being entered? - #3 by walter.
Or maybe you need to know that you can get the KeyboardEvent as the e.diagram.lastInput.event
, if it’s a keyboard event.