Background story: when a user selects a portion of text in a text field with her mouse (mark it up manually), and subsequently hits “alt” key, a certain function would trigger.
My questions are:
- How can I trigger a function when a
user hits a key (in her keyboard)? - How can I preserve a portion of text selected, and use it as a
parameter for that function?
I’ve tried looking up online but haven’t found any good answers, but i’d greatly appreciate links as well.
If you want to get the selected text in a text input or textarea you can do this: