JavaScript How to get selected text if Ctrl + Enter is pressed?

Veröffentlicht am: 24 Juni 2021
auf dem Kanal: Samovar tutorials
543
7

There is some site.
There is a text on that site.
To get selected text we need the document object and the getSelection method.
The getSelection method returns a Selection object.
We need toString method of the Selection object to get the selected text.
To check the Ctrl + Enter combination is pressed we need to add an event listener
and to test key and ctrlKey properties of the event object.
That’s all.
Let’s open the site, select a text part and press ctrl enter.
We have got the selected text.


Auf dieser Seite können Sie das Online-Video JavaScript How to get selected text if Ctrl + Enter is pressed? mit der Dauer online in guter Qualität ansehen, das der Benutzer Samovar tutorials 24 Juni 2021 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 543 Mal angesehen und es wurde von 7 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!