Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

334
Views
How to perform own action on F5 key press in UI5?

I don't know how to replace the F5 key action in SAPUI5.

I have a button "Refresh" which is reloading my business data in the UI and made some kind of manipulation before showing it on the view. I want to catch the F5-press so that my method to refresh can be called.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Since UI5 1.70 (commit:59b83bf), applications can define app-wide shortcuts in manifest.json and declare the corresponding event handlers in the view.

Here is a sample: https://embed.plnkr.co/NKOfisfY7w0MOiX8

In manifest.json:

"sap.ui5": {
  "commands": {
    "MyRefresh": {
      "shortcut": "F5"
    }

In the view:

<AnyUI5Control>
  <dependents>
    <core:CommandExecution xmlns:core="sap.ui.core"
      command="MyRefresh"
      execute=".onRefreshData"
    />
  </dependents>
</AnyUI5Control>

When the control has the focus, pressing F5 will trigger the event handler onRefreshData in the controller.


Please note that the custom shortcut feature in UI5:

  • Is supported since UI5 1.70.
  • Currently works only if the control has the focus. See the related discussion on GitHub.
  • Make sure your shortcut key combination doesn't overlap with the existing shortcuts that the target control already provides.
about 4 years ago · Juan Pablo Isaza Report

0

Just add an event listener to the window and call preventDefault() to stop it from doing the default thing of reloading.

(After running, click inside the white section to see it working. Otherwise the page will reload)

window.addEventListener("keydown", (event) => {
  if (event.key == "F5") event.preventDefault();
});

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!