Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

338
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda