3

I need to check if Shift key is pressed. More exactly I would like to set dired switches depending on whether Shift 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 can have different shortcuts for different dired switches, but I would like to change my switches dynamically during choosing a directory for dired.

Oleg Pavliv
  • 20,462
  • 7
  • 59
  • 75

1 Answers1

5

Duplicate question (ignoring the 'Windows' part of the other one).

Can I send a keypress to Windows from Emacs?

The best you can do (is as you mention) have different shortcuts. They can be differentiated by 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)
Community
  • 1
  • 1
Trey Jackson
  • 73,529
  • 11
  • 197
  • 229
  • I don't see this as a duplicate - the other question asks about sending a key, this one is about receiving one (or checking if one is pressed). – Paŭlo Ebermann Sep 04 '11 at 13:23