Expand my Community achievements bar.

SOLVED

how can I know user is typing or pasting in the search field

Avatar

Level 2

once we have the search terms, I need to know whether it is typed or pased in the search field. How can we achieve this?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

That one is tricky... what if they paste AND type? I assume you don't want to inflate your server calls by sending tracking on each keystroke or paste action (which may not even result in an actual search).

 

Do you plan on tracking "typed" vs "pasted" when the user submits their search? Do you want the last used?

 

So:

  • user pasted then typed, so send just "typed"?
  • or do you want to know if there was a mixed usage, so send "pasted and typed"?
  • what happens if the user types, deletes everything they typed, then pastes?
  • what happens is the user pastes over what they typed?
  • what happens if the user types over what they pasted?
  • what about accessible technologies? i.e. user has data type via voice input? There is no keyboard interaction in this scenario....

 

If you use the last interaction, that's easier... but may not provide the detail you need...  but if you try to track a combined usage you can see how complex this might get... 

 

All of this would require custom JS to detect Key Presses (which wouldn't work for assistive technologies, and storing / updating at each use, to then read/pull when the search is submitted.... 

 

While I am not going to presume to know why this is important to you / your business... it might be worth having a discussion about whether this particular use case is worth the complexities (which still may not be able to capture all scenarios with 100% accuracy any way)

 

 

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

That one is tricky... what if they paste AND type? I assume you don't want to inflate your server calls by sending tracking on each keystroke or paste action (which may not even result in an actual search).

 

Do you plan on tracking "typed" vs "pasted" when the user submits their search? Do you want the last used?

 

So:

  • user pasted then typed, so send just "typed"?
  • or do you want to know if there was a mixed usage, so send "pasted and typed"?
  • what happens if the user types, deletes everything they typed, then pastes?
  • what happens is the user pastes over what they typed?
  • what happens if the user types over what they pasted?
  • what about accessible technologies? i.e. user has data type via voice input? There is no keyboard interaction in this scenario....

 

If you use the last interaction, that's easier... but may not provide the detail you need...  but if you try to track a combined usage you can see how complex this might get... 

 

All of this would require custom JS to detect Key Presses (which wouldn't work for assistive technologies, and storing / updating at each use, to then read/pull when the search is submitted.... 

 

While I am not going to presume to know why this is important to you / your business... it might be worth having a discussion about whether this particular use case is worth the complexities (which still may not be able to capture all scenarios with 100% accuracy any way)