0

I have a button

<v-btn
 class="mt-2 mb-2 mr-2"
 @click="saveAntennas()"
 >Save</v-btn>

In saveAntennas() function, what should be the code, such that on clicking Ctrl + S must be triggered. Thank You in advance!

  • You can't emulate key strikes on the keyboard. What is the exact goal of this? – Teemu Apr 25 '22 at 09:34
  • Does this answer your question? [How do I capture a CTRL-S without jQuery or any other library?](https://stackoverflow.com/questions/11362106/how-do-i-capture-a-ctrl-s-without-jquery-or-any-other-library) – norbekoff Apr 25 '22 at 09:36
  • giving Ctrl + S will execute a set of python scripts and generate files. so I want it to save automatically by clicking a button. – Jacin Jacob Apr 25 '22 at 09:37
  • Does this answer your question? [Is it possible to simulate key press events programmatically?](https://stackoverflow.com/questions/596481/is-it-possible-to-simulate-key-press-events-programmatically) – mrtechtroid Apr 25 '22 at 09:51
  • You want that on your UI (on your Nuxt page), you click on a button and it does save something (current vue file?) and reload scripts somewhere? If the python scripts are local, then you should handle that on your development workflow configuration (Webpack watcher), like if your file is saved locally on your machine, it triggers some actions. If the python scripts are somewhere else, this should lead to an API call making those actions. The question is poorly phrased tho, because a `ctrl + s` on a page is used to save the current `HTML page` somewhere: out of Vue.js scope, more on an OS level – kissu Apr 25 '22 at 10:31
  • No no, its an already developed complex application which executes all these python scripts on pressing Ctrl + S, all I want is instead of pressing Ctrl + S on the keyboard, I want ctrl S to trigger if I click on a button. – Jacin Jacob Apr 25 '22 at 10:38
  • Hehe, please be far more precise as of the environment + context of what you're saying. `which executes all these python scripts on pressing Ctrl + S`, this is a behavior in your code editor, on your local machine, so we're talking about Webpack (/similar) right? Then, please be explicit as of what you want **exactly** because it's quite confusing right now. You cannot save a touched `.vue` file in your VScode from a webpage UI, if it's what you want to achieve. You could save your file in VScode when you lose the focus on your editor (like an `alt + tab` shortcut). Or is it something else? – kissu Apr 25 '22 at 10:49
  • I recommend you to look at this interesting discussion: https://stackoverflow.com/questions/45568824/listening-to-esc-key-event-on-div-component-in-vue-js – Florent Bouisset Apr 25 '22 at 19:07
  • @FlorentBouisset there is a deleted answer which is regarding the same topic, but this is not what OP wants so far. I'm quoting: "I want that button the execute Ctrl + S, not that on giving Ctrl S the function should execute." – kissu Apr 25 '22 at 23:49
  • Saving page using JavaScript is only supported in Internet Explorer (lol): https://stackoverflow.com/a/3530687/6762310 – Muge Apr 27 '22 at 15:42

0 Answers0