How do I get the focussed element in shiny?

Is there a way to find out in shiny whether the focus is on a text-field (or maybe select field)?

My website has a lot of elements like plots, tables, numerical inputs and buttons.

Currently I have something like this:

library(shiny)
ui <- fluidPage(
  tags$script('$(document).ready(function(){ $("*").focus( function(e){ Shiny.setInputValue("focusedElement", e.target.id);}); }); '),
  textOutput("output1"),
  textInput(inputId = "text1", label = 'Text1', value = ""),
  numericInput(inputId = 'num1',label = 'Num1', value=5),
  selectInput(inputId = 'select1', label='Select1',choices = c(1,2,3)),
  plotOutput('plot'),
  actionButton('btn','Btn'),
  DT::dataTableOutput('table'),
  
)

server <- function(input, output, session) {
  output$output1 <- renderText({ 
    print(input$focusedElement)
    input$focusedElement })
  output$table<- DT::renderDataTable(iris)
  output$plot<-renderPlot(plot(iris[,c(3,4)]))
}

shinyApp(ui, server)

Although I focussed every single input and the empty background, the only thing that works is Text-Input, Numerical-Input and Buttons. Why is that? (Take a look at the console output, select1 was definitely focussed at some point but never printed, also the search-bar and the plot and the background.)

Shiny app after having focussed every element

Please feel free to propose completely different approaches or correct my style.

What I want to know in the end is actually just whether I am in a text-field (like text1 or num1 or the search-bar of the table) or a button at the moment.