Elisp how to check if Shift key is pressed

I need to check if the Shift key is pressed. More precisely, I would like to set the Dired Switch depending on whether the Shift key is pressed.

(defadvice find-file-noselect (around find-file-noselect-set-switches activate)
  (let ((switches dired-listing-switches))
    ;; check if shift is pressed and set or not an "R" switch
    (setq dired-listing-switches "-lhRA")
    ad-do-it
    (setq dired-listing-switches switches)))

Of course, I may have different shortcuts for different switches, but I would like to dynamically change my switches when choosing a directory for dired.

+3
source share
1 answer

Duplicate question (ignoring the "Windows" part of another).

Can I send a Windows keystroke from Emacs?

The best you can do (as you mentioned) has different keyboard shortcuts. They can be differentiated due to capitalization ... for example

(global-set-key (kbd "C-x C-D") 'dired-with-some-switches)
(global-set-key (kbd "C-x C-d") 'dired-with-other-switches)
+5
source

Source: https://habr.com/ru/post/1718554/


All Articles