Re: Fwd: trapping key in case statement
Hi Alex Thank you very much for the explanation. Best Regards Dean On 12 January 2017 at 15:58, Alexander Burger wrote: > Hi Dean, > > > I can match the (key) value of backspace to BS using 'if' but am not sure > > how to using 'case' > > > > (setq BS "^?") > > Note that "^?" is DEL (ASCII 127), mapped to by some keyboard drivers when > the > backspace key is pressed. > > Backspace (ASCII 8) is "^H". > > > > (setq Key (key)) > > (if (= Key BS) (prinl "yes BS")) #works fine when backspace is pressed > > (case Key ("a" (prinl "a pressed"))) #works fine when "a" is pressed > > (case Key (BS (prinl "BS pressed"))) #??? > > 'case' does not evaluate the clauses. But as the value of BS is constant, > you > can use a read macro > >(case Key (`BS (prinl "BS pressed"))) > > > But better catch both values: > >(prinl > (case (key) > (("^H" "^?") "BS pressed") > (T "Other key pressed") ) ) > > ♪♫ Alex > -- > UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe >
Re: Fwd: trapping key in case statement
Hi Dean, > I can match the (key) value of backspace to BS using 'if' but am not sure > how to using 'case' > > (setq BS "^?") Note that "^?" is DEL (ASCII 127), mapped to by some keyboard drivers when the backspace key is pressed. Backspace (ASCII 8) is "^H". > (setq Key (key)) > (if (= Key BS) (prinl "yes BS")) #works fine when backspace is pressed > (case Key ("a" (prinl "a pressed"))) #works fine when "a" is pressed > (case Key (BS (prinl "BS pressed"))) #??? 'case' does not evaluate the clauses. But as the value of BS is constant, you can use a read macro (case Key (`BS (prinl "BS pressed"))) But better catch both values: (prinl (case (key) (("^H" "^?") "BS pressed") (T "Other key pressed") ) ) ♪♫ Alex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Fwd: trapping key in case statement
-- Forwarded message -- From: dean Date: 5 January 2017 at 22:15 Subject: trapping key in case statement To: picolisp@software-lab.de I can match the (key) value of backspace to BS using 'if' but am not sure how to using 'case' (setq BS "^?") (setq Key (key)) (if (= Key BS) (prinl "yes BS")) #works fine when backspace is pressed (case Key ("a" (prinl "a pressed"))) #works fine when "a" is pressed (case Key (BS (prinl "BS pressed"))) #???